Broadcast Datagram ServerClient Design

 < Day Day Up > 



Broadcast Datagram Server/Client Design

The broadcast datagram server and client utilize a UDP connection to communicate the date and time information from the broadcast server to the client. Because communication is broadcast, there is no physical connection between the client and server. The client need only subscribe to a broadcast port in order to receive broadcast datagrams. The server must use a socket option in order to generate broadcast datagrams, using the setsockopt call.

The data flow diagram illustrating the Sockets API calls for the broadcast client and server is shown in Figure 15.3.

click to expand
Figure 15.3: Broadcast datagram server/client data flow.

The server first creates a socket and then uses setsockopt to permit the transmission of broadcast datagrams. In order to receive broadcast datagrams, the client creates a socket and then binds it to the wildcard address (INADDR_ANY) and broadcast port.

The server uses the sendto API function to send the date and time datagram, directing it to the broadcast address and port. Because the client is already bound with the address and port information, a recvfrom API function is used to receive the broadcast datagram.

The broadcast server then simply acts as a time-based broadcaster of time and date information. The client simply binds itself to the broadcast channel, allowing it to receive any datagrams emitted to the broadcast address and port. This differs from our traditional clients and servers, but illustrates the mechanisms to create broadcast clients and servers.



 < Day Day Up > 



BSD Sockets Programming from a Multi-Language Perspective
Network Programming for Microsoft Windows , Second Edition (Microsoft Programming Series)
ISBN: 1584502681
EAN: 2147483647
Year: 2003
Pages: 225
Authors: Jim Ohlund

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net