In lab Assignment 3 - Using UDP sockets



TCP vs UDP

In the previous lab we worked with TCP sockets. At the transport layer though there is also another dominant protocol used, the UDP.

The main difference between TCP and UDP is that the first is connection oriented while the latter is connectionless. This means that in order to use UDP we don't need to connect to the server beforehand. Moreover the server doesn't need to listen to the connection requests from the clients. As a result a UDP client - server model is more easy to be implemented.

Of course there is a tradeoff. Because of its easiness UDP doesn't guarantee that the data will be delivered. Despite such situations UDP is still preferred in applications that can tolerate some data loss, like VOIP.

For a more detailed comparison of the two protocols you can click here.

In this lab assignment you are asked to implement the echo client/server using UDP sockets.

Tip 1: Just modify the TCPEchoClient and the TCPEchoServer you have already seen in the first lab.

Tip 2:Use sendto() and recvfrom() instead of send() and recv() respectively.