diff options
-rw-r--r-- | core/Messenger.c | 6 | ||||
-rw-r--r-- | core/network.c | 23 |
2 files changed, 17 insertions, 12 deletions
diff --git a/core/Messenger.c b/core/Messenger.c index 043700e5..042d5325 100644 --- a/core/Messenger.c +++ b/core/Messenger.c | |||
@@ -402,9 +402,9 @@ int initMessenger() | |||
402 | ip.i = 0; | 402 | ip.i = 0; |
403 | 403 | ||
404 | if(init_networking(ip,PORT) == -1) | 404 | if(init_networking(ip,PORT) == -1) |
405 | return -1; | 405 | return -1; |
406 | 406 | ||
407 | return 0; | 407 | return 0; |
408 | } | 408 | } |
409 | 409 | ||
410 | static void doFriends() | 410 | static void doFriends() |
diff --git a/core/network.c b/core/network.c index bc6738ac..05dc9962 100644 --- a/core/network.c +++ b/core/network.c | |||
@@ -103,7 +103,7 @@ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length) | |||
103 | port is in host byte order (this means don't worry about it) | 103 | port is in host byte order (this means don't worry about it) |
104 | returns 0 if no problems | 104 | returns 0 if no problems |
105 | returns -1 if there are problems */ | 105 | returns -1 if there are problems */ |
106 | int init_networking(IP ip ,uint16_t port) | 106 | int init_networking(IP ip, uint16_t port) |
107 | { | 107 | { |
108 | #ifdef WIN32 | 108 | #ifdef WIN32 |
109 | WSADATA wsaData; | 109 | WSADATA wsaData; |
@@ -120,14 +120,14 @@ int init_networking(IP ip ,uint16_t port) | |||
120 | /* initialize our socket */ | 120 | /* initialize our socket */ |
121 | sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); | 121 | sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
122 | 122 | ||
123 | /* Check for socket error */ | 123 | /* Check for socket error */ |
124 | #ifdef WIN32 | 124 | #ifdef WIN32 |
125 | if (sock == INVALID_SOCKET) //MSDN recommends this | 125 | if (sock == INVALID_SOCKET) //MSDN recommends this |
126 | return -1; | 126 | return -1; |
127 | #else | 127 | #else |
128 | if (sock < 0) | 128 | if (sock < 0) |
129 | return -1; | 129 | return -1; |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | 132 | ||
133 | /* Functions to increase the size of the send and receive UDP buffers | 133 | /* Functions to increase the size of the send and receive UDP buffers |
@@ -144,6 +144,11 @@ int init_networking(IP ip ,uint16_t port) | |||
144 | return -1; | 144 | return -1; |
145 | }*/ | 145 | }*/ |
146 | 146 | ||
147 | /*Enable broadcast on socket*/ | ||
148 | int broadcast = 1; | ||
149 | setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&broadcast, sizeof(broadcast)); | ||
150 | |||
151 | |||
147 | /* Set socket nonblocking */ | 152 | /* Set socket nonblocking */ |
148 | #ifdef WIN32 | 153 | #ifdef WIN32 |
149 | /* I think this works for windows */ | 154 | /* I think this works for windows */ |