Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Fixed ofxOsc Broadcast to 255.255.255.255 in OF 0.84 under Windows

$
0
0

I spent almost three hours finding this one, so I'd like to let you guys know...

Calling ofxOscSender.setup() with the local network broadcast-address (255.255.255.255) under windows throws an exception ("std::runtime_error("unable to connect udp socket\n");") in UdpSocket::Implementation::Connect() located in the file "UdbSocketWin.cpp".

This is because the broadcast address is translated to 0.0.0.0 in SockaddrFromIpEndpointName. Fixing SockaddrFromIpEndpointName is hard because that behavior is expected in other places. (Setting up a Receiver will fail if you do)

As a quick and dirty sollution, modify UdpSocket::Implementation::Connect() in File "UdbSocketWin.cpp" as follows to make things work:

    void Connect( const IpEndpointName& remoteEndpoint )
    {
        SockaddrFromIpEndpointName( connectedAddr_, remoteEndpoint );
        // fix to allow local broadcasts
        if(remoteEndpoint.address==IpEndpointName::ANY_ADDRESS){
            connectedAddr_.sin_addr.s_addr=INADDR_BROADCAST;
        }
        //end fix


        if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) {
            throw std::runtime_error("unable to connect udp socket\n");
        }

        isConnected_ = true;
    }

Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>