diff options
Diffstat (limited to 'core/DHT.c')
-rw-r--r-- | core/DHT.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -15,14 +15,16 @@ int sendpacket(IP_Port ip_port, char * data, uint32_t length) | |||
15 | //Function to recieve data, ip and port of sender is put into ip_port | 15 | //Function to recieve data, ip and port of sender is put into ip_port |
16 | //the packet data into data | 16 | //the packet data into data |
17 | //the packet length into length. | 17 | //the packet length into length. |
18 | //dump all empty packets. | ||
18 | int recievepacket(IP_Port * ip_port, char * data, uint32_t * length) | 19 | int recievepacket(IP_Port * ip_port, char * data, uint32_t * length) |
19 | { | 20 | { |
20 | ADDR addr; | 21 | ADDR addr; |
21 | uint32_t addrlen = sizeof(addr); | 22 | uint32_t addrlen = sizeof(addr); |
22 | (*(int *)length) = recvfrom(sock, data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); | 23 | (*(int *)length) = recvfrom(sock, data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); |
23 | if(*(int *)length == -1) | 24 | if(*(int *)length <= 0) |
24 | { | 25 | { |
25 | //nothing recieved | 26 | //nothing recieved |
27 | //or empty packet | ||
26 | return -1; | 28 | return -1; |
27 | } | 29 | } |
28 | ip_port->ip = addr.ip; | 30 | ip_port->ip = addr.ip; |