Distributed Systems Lab 3 - TCP/IP connections in Java


Objectives

Overview

TCP and UDP are example protocols at the "Transport" layer in the OSI model of network architecture
TCP
UDP

...About Sockets...

Sockets are essentially end points for communication, analagous to telephones on a telephone line. You need to have one on each end in order for there to be communication. So before you use a program to talk using UDP or TCP you need to open a socket. When you open a socket you bind (binding is like plugging in) it to a specific IP address and port. After a socket is bound it is ready to send and receive data. At least in UNIX type systems, sockets are like file descriptors. So the important thing to remember is that they need to be properly opened and closed like files in order to keep things from getting messy. Trying to bind multiple sockets to the same port on a computer can cause conflicts. Also, when you create a socket it comes back to you as a socket descriptor number, this descriptor is the handle for the socket and is how you will refer to it in the future.

A final bit to remember about sockets is that they have both sending and receiving buffers associated with them. In relation to UDP the sending buffer does not have much relevance as long as it is bigger than any single packet you will send. On the receiving side, a socket will store up UDP packets in the buffer until the buffer is full. Of course, when you read a packet from the socket it will remove it from the buffer. When the buffer is full any more packets going to the buffer will be lost. So if you are sending data at high speeds and your packet reading application can't keep up with the sender it is important to keep in mind that the buffer may have some kind of effect on your program's behavior.

Task 1: Retrieving web pages using TCP sockets

Task 2: Client/server interaction using UDP sockets

Task 3:

Documenting Java code

Question: