better broadcast support
[chaz/yoink] / src / Moof / Socket.hh
index f1604663b038c37ff408061ca50db4d914ccd38a..6b0fa88fa6bbe7a72c52eef4773687f217c4a351 100644 (file)
@@ -90,7 +90,16 @@ public:
 
        static SocketAddress broadcast(const std::string& service)
        {
-               return SocketAddress(service, "255.255.255.255", SOCK_DGRAM);
+               std::istringstream stream(service);
+               unsigned short port;
+               stream >> port;
+
+               struct sockaddr_in addr;
+               addr.sin_family = AF_INET;
+               addr.sin_port = htons(port);
+               addr.sin_addr.s_addr = INADDR_BROADCAST;
+               memset(&addr.sin_zero, 0, sizeof(addr.sin_zero));
+               return SocketAddress((sockaddr*)&addr, sizeof(addr), SOCK_DGRAM);
        }
 
 
This page took 0.018826 seconds and 4 git commands to generate.