Feature #1685
Add support for broadcast sockets
| Status: | Closed | Start date: | 2016-05-14 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% | |
| Category: | - | |||
| Target version: | - |
Description
This should do it, just make sure it does not cause issues with non-broadcast sockets.
diff -r 381f352c44eb core/UdpClient.cpp
--- a/core/UdpClient.cpp Wed May 11 10:29:23 2016 +0100
+++ b/core/UdpClient.cpp Sat May 14 21:02:45 2016 +0100
@@ -8,6 +8,9 @@
UdpClient::UdpClient(){
outSocket=socket(AF_INET, SOCK_DGRAM, 0);
+ int broadcastEnable = 1;
+ int ret = setsockopt(outSocket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
+ printf("setsockopt returned %d\n", ret);
isSetPort=false;
isSetServer=false;
enabled=false;
@@ -74,4 +77,4 @@
stTimeOut.tv_usec=(int)(timeOutSecs*1000000);
int descriptorReady= select(outSocket+1, NULL, &stWriteFDS, NULL, &stTimeOut);
return descriptorReady>0? 1 : descriptorReady;
- }
\ No newline at end of file
+ }