In the code below, a Datagram (UDP) Socket is created with several options (including broadcasting).
int MySocketUsingClass::SetupASocket(u_short nPeerPortInNetworkOrder, char* szPeerIPAddressDottedDecimal)
{
TINetSocketAddress myAddress;
TINetSocketAddress peerAddress(nPeerPortInNetworkOrder, szPeerIPAddressDottedDecimal);
TDatagramSocket myDatagramSocket(myAddress);
myDatagramSocket.CreateSocket();
myDatagramSocket.BindSocket();
myDatagramSocket.SetBroadcastOption(TRUE);
myDatagramSocket.SetDebugOption(TRUE);
debugging information.
myDatagramSocket.SetLingerOption(TRUE, 5);
myDatagramSocket.SetSendBufferOption(512);
bytes.
myDatagramSocket.SetPeerAddress(TINetSocketAddress(ntohs(N_PORT), INADDR_BROADCAST);
}