Archive

Archive for the ‘Networking’ Category

Enabling broadcast option on a socket!

March 30, 2008 Leave a comment

In order to enable broadcasting option on a socket you’ve got to enable it via a call to setsockopt with optname set to SO_BROADCAST and level set to SOL_SOCKET!

Here is a function which does this!

bool SetBroadcastOn( const bool Enable )
{
    const BOOL bEnable = Enable;
    if( setsockopt( sckHandle,
                    SOL_SOCKET,
                    SO_BROADCAST,
                    (const char*)&bEnable ,
                    sizeof( blEnable )) != 0 )
    {
        return false;
    }   

    // Success
    return true;
}// End EnableBroadcast
%d bloggers like this: