UDP Broadcast and Endpoint.set_address()

08 Sep 2012

Hi Emilio, Please add

    int set_broadcast(bool bBroadcast = true)
    {   int val = (bBroadcast != 0);
    
        return lwip_setsockopt(_sock_fd,SOL_SOCKET,SO_BROADCAST,&val,sizeof(val));
    }

to UDPSocket

Also,

Endpoint ep;

ep.set_address("255.255.255.255",0);

set_address fails with a return value of -1, but

class Endpoint2 : public Endpoint
{
public:
    int set_address(uint32_t ip, uint16_t port)
    {
        reset_address();

        _remoteHost.sin_addr.s_addr = htonl(ip);
        _remoteHost.sin_family = AF_INET;
        _remoteHost.sin_port = htons(port);

        return 0;
    }
};

Endpoint2 ep

ep.set_address(0xFFFFFFF,0);

works as expected when used with UDPSocket.set_broadcast()

Thanks

08 Sep 2012

Ooopps... This should've been in bugs and suggestions... sorry.