Monday, November 26, 2012

Sixth lab: UDP Sockets

This lab teaches you taht the use of UDP sockets is quite different from TCP. While the service offered is simpler, the programming details become a bit awkward. There are three main classes involved:
  1. InetAddress used mostly for DNS queries and for representing destination addresses.
  2. DatagramSocket as the endpoint of each datagram exchange.
  3. DatagramPacket as the data exchanged through DatagramSocket objects.
InetAddress methods getByName and getAllByName will be used to obtain the IP adresses of a host. And send and receive methods of DatagramSocket objects will be used for exchanging DatagramPacket objects between hosts. 

Remember that UDP has not the concept of a connection, so a server can receive datagrams belonging to different conversations (with different clients) through the same socket. 

There is not such a thing as a DatagramServerSocket.

No comments:

Post a Comment