Home > Networking, Windows API > Enabling broadcast option on a socket!

Enabling broadcast option on a socket!

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
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: