diff options
-rw-r--r-- | toxcore/network.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/toxcore/network.c b/toxcore/network.c index 8d5b25b4..725ce604 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -204,16 +204,18 @@ void networking_poll(Networking_Core *net) | |||
204 | IP_Port ip_port; | 204 | IP_Port ip_port; |
205 | uint8_t data[MAX_UDP_PACKET_SIZE]; | 205 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
206 | uint32_t length; | 206 | uint32_t length; |
207 | 207 | int recverr; | |
208 | while (length = sizeof(data), receivepacket(net->sock, &ip_port, data, &length) != -1) { | 208 | do { |
209 | if (length < 1) | 209 | length = sizeof(data); |
210 | continue; | 210 | recverr = receivepacket(net->sock, &ip_port, data, &length); |
211 | 211 | if (!recverr && (length > 0)) { | |
212 | if (!(net->packethandlers[data[0]].function)) | 212 | if (!(net->packethandlers[data[0]].function)) |
213 | continue; | 213 | continue; |
214 | 214 | ||
215 | net->packethandlers[data[0]].function(net->packethandlers[data[0]].object, ip_port, data, length); | 215 | net->packethandlers[data[0]].function(net->packethandlers[data[0]].object, |
216 | } | 216 | ip_port, data, length); |
217 | } | ||
218 | } while (recverr != -1); | ||
217 | } | 219 | } |
218 | 220 | ||
219 | uint8_t at_startup_ran = 0; | 221 | uint8_t at_startup_ran = 0; |