Stream sockets

We will see more in particular of this type of socket only. Being based on transport layer protocols such as TCP, they guarantee a reliable, full-duplex, and connection-oriented communication, with a variable-length byte stream.

Communication through this socket consists of these phases:

  1. Creation of sockets: Clients and servers create their respective sockets, and the server listens to them on a port. Since the server can create multiple connections with different clients (but also with the same one), it needs a queue to handle the various requests.
  2. Connection request: The client requests a connection to the server. Note that we can have different port numbers because one could only be assigned to the outgoing traffic, and the other only to entry. This depends on the host configuration. Essentially, the client's local port does not necessarily coincide with the server's remote port. The server receives the request and, if accepted, a new connection is created. In the diagram, the port of the client socket is 8080, while for the socket server, the port is 80.
  3. Communication: Now, the client and server communicate through a virtual channel, between the client's socket, and a new socket (server side), created specifically for the data flow of this connection: a data socket. As it was mentioned in the first phase, the server creates the data socket because the first data socket is used exclusively for managing requests. Therefore, it is possible that there are many clients communicating with the server, each with the data socket specifically created by the server for them.
  4. Closure of the connection: Since the TCP is a connection-oriented protocol when there is no longer a need to communicate, the client communicates it to the server, which deallocates the data socket.

The phases of communication through stream sockets are shown in the following diagram:

     Stream socket phases
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.203.143