diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-27 08:26:00 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-27 08:26:00 -0400 |
commit | 1a6446266c9727e5c95e18d5e44157fd5a60900f (patch) | |
tree | 6dafbf52b7952f68a95ac9317871e923db6cc565 /core/network.c | |
parent | 45b5ef0b79239167d9bc8fe52b25b36b684d2687 (diff) | |
parent | 241aca98bdc8106221ee7d7dbcea9f2fa17f24bc (diff) |
Merge branch 'master' of https://github.com/KostyaKow/ProjectTox-Core into KostyaKow-master
Conflicts:
core/DHT.c
Diffstat (limited to 'core/network.c')
-rw-r--r-- | core/network.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/core/network.c b/core/network.c index ec234593..8804ab4e 100644 --- a/core/network.c +++ b/core/network.c | |||
@@ -79,13 +79,10 @@ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length) | |||
79 | #else | 79 | #else |
80 | uint32_t addrlen = sizeof(addr); | 80 | uint32_t addrlen = sizeof(addr); |
81 | #endif | 81 | #endif |
82 | (*(int32_t *)length) = recvfrom(sock,(char *) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&addr, &addrlen); | 82 | (*(int32_t*)length) = recvfrom(sock,(char*) data, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr*)&addr, &addrlen); |
83 | if(*(int32_t *)length <= 0) | 83 | if (*(int32_t*)length <= 0) |
84 | { | 84 | return -1; /* nothing received or empty packet */ |
85 | /* nothing received | 85 | |
86 | or empty packet */ | ||
87 | return -1; | ||
88 | } | ||
89 | ip_port->ip = addr.ip; | 86 | ip_port->ip = addr.ip; |
90 | ip_port->port = addr.port; | 87 | ip_port->port = addr.port; |
91 | return 0; | 88 | return 0; |
@@ -101,7 +98,7 @@ int init_networking(IP ip, uint16_t port) | |||
101 | { | 98 | { |
102 | #ifdef WIN32 | 99 | #ifdef WIN32 |
103 | WSADATA wsaData; | 100 | WSADATA wsaData; |
104 | if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) | 101 | if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) |
105 | return -1; | 102 | return -1; |
106 | #else | 103 | #else |
107 | srandom((uint32_t)current_time()); | 104 | srandom((uint32_t)current_time()); |