diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/network.c | 8 | ||||
-rw-r--r-- | toxcore/network.h | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/toxcore/network.c b/toxcore/network.c index 34775570..d8ae7750 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -60,7 +60,11 @@ uint32_t random_int(void) | |||
60 | /* Basic network functions: | 60 | /* Basic network functions: |
61 | * Function to send packet(data) of length length to ip_port. | 61 | * Function to send packet(data) of length length to ip_port. |
62 | */ | 62 | */ |
63 | #ifdef WIN32 | ||
64 | int sendpacket(unsigned int sock, IP_Port ip_port, uint8_t *data, uint32_t length) | ||
65 | #else | ||
63 | int sendpacket(int sock, IP_Port ip_port, uint8_t *data, uint32_t length) | 66 | int sendpacket(int sock, IP_Port ip_port, uint8_t *data, uint32_t length) |
67 | #endif | ||
64 | { | 68 | { |
65 | ADDR addr = {AF_INET, ip_port.port, ip_port.ip}; | 69 | ADDR addr = {AF_INET, ip_port.port, ip_port.ip}; |
66 | return sendto(sock, (char *) data, length, 0, (struct sockaddr *)&addr, sizeof(addr)); | 70 | return sendto(sock, (char *) data, length, 0, (struct sockaddr *)&addr, sizeof(addr)); |
@@ -72,7 +76,11 @@ int sendpacket(int sock, IP_Port ip_port, uint8_t *data, uint32_t length) | |||
72 | * Packet length is put into length. | 76 | * Packet length is put into length. |
73 | * Dump all empty packets. | 77 | * Dump all empty packets. |
74 | */ | 78 | */ |
79 | #ifdef WIN32 | ||
80 | static int receivepacket(unsigned int sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) | ||
81 | #else | ||
75 | static int receivepacket(int sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) | 82 | static int receivepacket(int sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) |
83 | #endif | ||
76 | { | 84 | { |
77 | ADDR addr; | 85 | ADDR addr; |
78 | #ifdef WIN32 | 86 | #ifdef WIN32 |
diff --git a/toxcore/network.h b/toxcore/network.h index 32850944..3a1c75f8 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -120,7 +120,12 @@ typedef struct { | |||
120 | typedef struct { | 120 | typedef struct { |
121 | Packet_Handles packethandlers[256]; | 121 | Packet_Handles packethandlers[256]; |
122 | /* Our UDP socket. */ | 122 | /* Our UDP socket. */ |
123 | #ifdef WIN32 | ||
124 | unsigned int sock; | ||
125 | #else | ||
123 | int sock; | 126 | int sock; |
127 | #endif | ||
128 | |||
124 | } Networking_Core; | 129 | } Networking_Core; |
125 | 130 | ||
126 | /* return current time in milleseconds since the epoch. */ | 131 | /* return current time in milleseconds since the epoch. */ |
@@ -134,7 +139,12 @@ uint32_t random_int(void); | |||
134 | /* Basic network functions: */ | 139 | /* Basic network functions: */ |
135 | 140 | ||
136 | /* Function to send packet(data) of length length to ip_port. */ | 141 | /* Function to send packet(data) of length length to ip_port. */ |
142 | #ifdef WIN32 | ||
143 | int sendpacket(unsigned int sock, IP_Port ip_port, uint8_t *data, uint32_t length); | ||
144 | #else | ||
137 | int sendpacket(int sock, IP_Port ip_port, uint8_t *data, uint32_t length); | 145 | int sendpacket(int sock, IP_Port ip_port, uint8_t *data, uint32_t length); |
146 | #endif | ||
147 | |||
138 | 148 | ||
139 | /* Function to call when packet beginning with byte is received. */ | 149 | /* Function to call when packet beginning with byte is received. */ |
140 | void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object); | 150 | void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object); |