changed udp.c to properly detect compiling on windows with tcc

master
bx 2021-12-29 00:36:21 +00:00
parent 6b3c8210b5
commit 91f280ba3a
1 changed files with 6 additions and 6 deletions

12
udp.c
View File

@ -8,7 +8,7 @@
* store from ip + port in message ?
*/
#ifdef __WIN32__
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
@ -26,13 +26,13 @@
#undef while
// G l o b a L E v i L //
#ifdef __WIN32__
#ifdef _WIN32
static SOCKET udp_sock;
#else
static int udp_sock;
#endif
#ifdef __WIN32__
#ifdef _WIN32
void udp_init(Ampler_state *state) {
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsastartup
WSADATA wsa;
@ -71,7 +71,7 @@ void udp_init(Ampler_state *state) {
}
#endif
#ifdef __WIN32__
#ifdef _WIN32
void udp_quit(Ampler_state *state) {
closesocket(udp_sock);
WSACleanup();
@ -82,7 +82,7 @@ void udp_quit(Ampler_state *state) {
}
#endif
#ifdef __WIN32__
#ifdef _WIN32
void recv_packet(Ampler_state *state) {
char discard_buf[32] = { 0 }; // for dropped packets
char *buf = discard_buf;
@ -128,7 +128,7 @@ void recv_packet(Ampler_state *state) {
}
#endif
#ifdef __WIN32__
#ifdef _WIN32
void udp_frame(Ampler_state *state) {
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
fd_set recv_fd_set;