OWLNext
7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Creating a Datagram Socket
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
;
//(port 0, address INADDR_ANY)
TINetSocketAddress
peerAddress
(
nPeerPortInNetworkOrder
,
szPeerIPAddressDottedDecimal
);
TDatagramSocket
myDatagramSocket
(
myAddress
);
myDatagramSocket
.CreateSocket();
myDatagramSocket
.BindSocket();
myDatagramSocket
.SetBroadcastOption(
TRUE
);
//enable broadcasting.
myDatagramSocket
.SetDebugOption(
TRUE
);
//record
debugging
information
.
myDatagramSocket.SetLingerOption(
TRUE
, 5);
//set linger to 5 seconds.
myDatagramSocket
.SetSendBufferOption(512);
//set send buffer size to 512
bytes.
myDatagramSocket.SetPeerAddress(TINetSocketAddress(
ntohs
(
N_PORT
),
INADDR_BROADCAST
);
}
VarType
Definition
safearray.h:14
OWLNext
Overview of ObjectWindows
Overview of the Windows Socket Classes
Datagram Socket Communication
Generated by
1.10.0