56 |
|
#define MONITOR 0 |
57 |
|
|
58 |
|
|
59 |
+ |
#ifdef __BEOS__ |
60 |
+ |
#define CLOSESOCKET closesocket |
61 |
+ |
#else |
62 |
+ |
#define CLOSESOCKET close |
63 |
+ |
#endif |
64 |
+ |
|
65 |
+ |
|
66 |
|
// Global variables |
67 |
|
uint8 ether_addr[6]; // Ethernet address (set by ether_init()) |
68 |
|
static bool net_open = false; // Flag: initialization succeeded, network device open (set by EtherInit()) |
108 |
|
sa.sin_port = htons(udp_port); |
109 |
|
if (bind(udp_socket, (struct sockaddr *)&sa, sizeof(sa)) < 0) { |
110 |
|
perror("bind"); |
111 |
< |
close(udp_socket); |
111 |
> |
CLOSESOCKET(udp_socket); |
112 |
|
udp_socket = -1; |
113 |
|
return; |
114 |
|
} |
137 |
|
|
138 |
|
// Set socket options |
139 |
|
int on = 1; |
140 |
+ |
#ifdef __BEOS__ |
141 |
+ |
setsockopt(udp_socket, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(on)); |
142 |
+ |
#else |
143 |
|
setsockopt(udp_socket, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)); |
144 |
|
ioctl(udp_socket, FIONBIO, &on); |
145 |
+ |
#endif |
146 |
|
|
147 |
|
// Start thread for packet reception |
148 |
|
if (!ether_start_udp_thread(udp_socket)) { |
149 |
< |
close(udp_socket); |
149 |
> |
CLOSESOCKET(udp_socket); |
150 |
|
udp_socket = -1; |
151 |
|
return; |
152 |
|
} |
170 |
|
if (udp_tunnel) { |
171 |
|
if (udp_socket >= 0) { |
172 |
|
ether_stop_udp_thread(); |
173 |
< |
close(udp_socket); |
173 |
> |
CLOSESOCKET(udp_socket); |
174 |
|
udp_socket = -1; |
175 |
|
} |
176 |
|
} else |