From 63375b68b63d33c8437f313b2041b559c32c945b Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 25 Jul 2013 21:00:31 -0400 Subject: Broadcast now enabled on socket. --- core/network.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'core/network.c') 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) port is in host byte order (this means don't worry about it) returns 0 if no problems returns -1 if there are problems */ -int init_networking(IP ip ,uint16_t port) +int init_networking(IP ip, uint16_t port) { #ifdef WIN32 WSADATA wsaData; @@ -120,14 +120,14 @@ int init_networking(IP ip ,uint16_t port) /* initialize our socket */ sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - /* Check for socket error */ - #ifdef WIN32 - if (sock == INVALID_SOCKET) //MSDN recommends this - return -1; - #else - if (sock < 0) - return -1; - #endif + /* Check for socket error */ + #ifdef WIN32 + if (sock == INVALID_SOCKET) //MSDN recommends this + return -1; + #else + if (sock < 0) + return -1; + #endif /* Functions to increase the size of the send and receive UDP buffers @@ -144,6 +144,11 @@ int init_networking(IP ip ,uint16_t port) return -1; }*/ + /*Enable broadcast on socket*/ + int broadcast = 1; + setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&broadcast, sizeof(broadcast)); + + /* Set socket nonblocking */ #ifdef WIN32 /* I think this works for windows */ -- cgit v1.2.3