Mercurial > repos > blastem
comparison megawifi.c @ 1546:1a09422b87a5
Get Windows build working again. MegaWiFi code probably needs more work before it will actually work on Windows, but at least it doesn't break the build now
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 26 Mar 2018 21:25:40 -0700 |
parents | 2781b9551004 |
children | 6d99bdbf1e3e |
comparison
equal
deleted
inserted
replaced
1545:3faf917bab56 | 1546:1a09422b87a5 |
---|---|
1 #include <stdlib.h> | 1 #include <stdlib.h> |
2 #include <stdint.h> | 2 #include <stdint.h> |
3 #include <string.h> | 3 #include <string.h> |
4 #include <sys/types.h> | 4 #include <sys/types.h> |
5 #ifdef _WIN32 | |
6 #define WINVER 0x501 | |
7 #include <winsock2.h> | |
8 #include <ws2tcpip.h> | |
9 #else | |
5 #include <sys/socket.h> | 10 #include <sys/socket.h> |
6 #include <unistd.h> | 11 #include <unistd.h> |
7 #include <netinet/in.h> | 12 #include <netinet/in.h> |
13 #endif | |
8 #include <errno.h> | 14 #include <errno.h> |
9 #include <fcntl.h> | 15 #include <fcntl.h> |
10 #include "genesis.h" | 16 #include "genesis.h" |
11 #include "net.h" | 17 #include "net.h" |
12 | 18 |
123 } | 129 } |
124 if (mw->channel_state[channel] == 1) { | 130 if (mw->channel_state[channel] == 1) { |
125 int res = accept(mw->sock_fds[channel], NULL, NULL); | 131 int res = accept(mw->sock_fds[channel], NULL, NULL); |
126 if (res >= 0) { | 132 if (res >= 0) { |
127 close(mw->sock_fds[channel]); | 133 close(mw->sock_fds[channel]); |
134 #ifndef _WIN32 | |
135 //FIXME: Set nonblocking on Windows too | |
128 fcntl(res, F_SETFL, O_NONBLOCK); | 136 fcntl(res, F_SETFL, O_NONBLOCK); |
137 #endif | |
129 mw->sock_fds[channel] = res; | 138 mw->sock_fds[channel] = res; |
130 mw->channel_state[channel] = 2; | 139 mw->channel_state[channel] = 2; |
131 mw->channel_flags |= 1 << (channel + 1); | 140 mw->channel_flags |= 1 << (channel + 1); |
132 } else if (errno != EAGAIN && errno != EWOULDBLOCK) { | 141 } else if (errno != EAGAIN && errno != EWOULDBLOCK) { |
133 close(mw->sock_fds[channel]); | 142 close(mw->sock_fds[channel]); |
282 close(mw->sock_fds[channel]); | 291 close(mw->sock_fds[channel]); |
283 mw->sock_fds[channel] = -1; | 292 mw->sock_fds[channel] = -1; |
284 } else { | 293 } else { |
285 mw->channel_flags |= 1 << (channel + 1); | 294 mw->channel_flags |= 1 << (channel + 1); |
286 mw->channel_state[channel] = 1; | 295 mw->channel_state[channel] = 1; |
296 #ifndef _WIN32 | |
297 //FIXME: Set nonblocking on Windows too | |
287 fcntl(mw->sock_fds[channel], F_SETFL, O_NONBLOCK); | 298 fcntl(mw->sock_fds[channel], F_SETFL, O_NONBLOCK); |
299 #endif | |
288 } | 300 } |
289 end_reply(mw); | 301 end_reply(mw); |
290 break; | 302 break; |
291 } | 303 } |
292 case CMD_SOCK_STAT: { | 304 case CMD_SOCK_STAT: { |