- TCP Versus UDP
- Writing a Datagram Program
- Catching the Message
- Multicasting Datagrams
- Aligning Functionality
Even with the limitations of multicast, you can tune up your broadcast messaging with virtual conferences and file distribution. Remember to use the transport protocol (either TCP, UDP, or multicast) based on the best fit for the application. If you try to shoehorn one protocol into an ill-suited implementation, you may have to pad it with custom programming to avoid unexpected results.
TCP fits best with a connected, reliable communication in which security and integrity is important. The datagram protocols are best for single (one-shot) messages that need only a one-shot reply (if any). Also, multicasting builds on top of datagrams and gives you the capability to blast a message generally to anyone listening. It also has the potential disadvantage of increasing data inflow or even flooding.
This article described the different parts of datagram programming. The next article in this two-part series takes the discussion further by describing how to create an intermediate protocola reliable datagram protocol. It also demonstrates the functionality with a tool that allows very large files (such as ISO CD-ROM images) to be transmitted to several destinations without hogging the server or network. Linux Socket Programming goes into much greater detail on all levels of socket programming, and you can get source code for this article from the Linux Socket web site.