changed udp.c to properly detect compiling on windows with tcc
parent
6b3c8210b5
commit
91f280ba3a
12
udp.c
12
udp.c
|
@ -8,7 +8,7 @@
|
||||||
* store from ip + port in message ?
|
* store from ip + port in message ?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -26,13 +26,13 @@
|
||||||
#undef while
|
#undef while
|
||||||
|
|
||||||
// G l o b a L E v i L //
|
// G l o b a L E v i L //
|
||||||
#ifdef __WIN32__
|
#ifdef _WIN32
|
||||||
static SOCKET udp_sock;
|
static SOCKET udp_sock;
|
||||||
#else
|
#else
|
||||||
static int udp_sock;
|
static int udp_sock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef _WIN32
|
||||||
void udp_init(Ampler_state *state) {
|
void udp_init(Ampler_state *state) {
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsastartup
|
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsastartup
|
||||||
WSADATA wsa;
|
WSADATA wsa;
|
||||||
|
@ -71,7 +71,7 @@ void udp_init(Ampler_state *state) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef _WIN32
|
||||||
void udp_quit(Ampler_state *state) {
|
void udp_quit(Ampler_state *state) {
|
||||||
closesocket(udp_sock);
|
closesocket(udp_sock);
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
@ -82,7 +82,7 @@ void udp_quit(Ampler_state *state) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef _WIN32
|
||||||
void recv_packet(Ampler_state *state) {
|
void recv_packet(Ampler_state *state) {
|
||||||
char discard_buf[32] = { 0 }; // for dropped packets
|
char discard_buf[32] = { 0 }; // for dropped packets
|
||||||
char *buf = discard_buf;
|
char *buf = discard_buf;
|
||||||
|
@ -128,7 +128,7 @@ void recv_packet(Ampler_state *state) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef _WIN32
|
||||||
void udp_frame(Ampler_state *state) {
|
void udp_frame(Ampler_state *state) {
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
|
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
|
||||||
fd_set recv_fd_set;
|
fd_set recv_fd_set;
|
||||||
|
|
Loading…
Reference in New Issue