diff options
Diffstat (limited to 'core/network.c')
-rw-r--r-- | core/network.c | 23 |
1 files changed, 14 insertions, 9 deletions
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 */ |