Using Datagram Packets and UDP Sockets

The other approach to coding with sockets is to use UDP sockets. Unlike TCP sockets, UDP sockets do not create a connection between client and server, but rather they take a "fire and forget" approach. That is, your client or server sends a Datagram packet to the other system and then goes on with other work. Sometime later, the other system should receive the packet, but, in general, there is no way for the sender to be sure that the packet arrived successfully. UDP sockets allow you to write programs that use asynchronous communication, programs in which objectA sends data out on the network and then goes on with its work, while objectB waits on its socket to receive input. This is an appropriate structure ...

Get PURE Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.