2161CS136 Distributed Systems: Unit II Process and Distributed Objects Lecture No.12 TCP Stream Communication
2161CS136 Distributed Systems: Unit II Process and Distributed Objects Lecture No.12 TCP Stream Communication
2161CS136
DISTRIBUTED SYSTEMS
Unit II Process and Distributed Objects
Lecture No.12 TCP Stream communication
School of Computing
Vel Tech Rangarajan Dr. Sagunthala R&D Institute of
Science and Technology
Interprocess communication
Learning objective:
• The API to the TCP protocol, which originates from BSD 4.x UNIX,
provides the abstraction of a stream of bytes to which data may be written
and from which data may be read.
The client role involves creating a stream socket bound to any port and then
making a connect request asking for a connection to a server at its server port.
The server role involves creating a listening socket bound to a server port and
waiting for clients to request connections.
In the socket model, when the server accepts a connection, a new stream socket
is created for the server to communicate with a client, meanwhile retaining its
socket at the server port for listening for connect requests from other clients..
Issues related to stream communication
• The data items sent by the producer to the consumer are queued on arrival at
the receiving host until the consumer is ready to receive them.
• The producer must wait if the storage used to hold the queued data items is
exhausted.
The API for the Internet protocols
• For the sake of the validity property, TCP streams use timeouts and
retransmissions to deal with lost packets. Therefore, messages are guaranteed
to be delivered even when some of the underlying packets are lost.
• But if the packet loss over a connection passes some limit or the network
connecting a pair of communicating processes is severed or becomes severely
congested, the TCP software responsible for sending messages will receive no
acknowledgements and after a time will declare the connection to be broken.
• Thus TCP does not provide reliable communication, because it does not
guarantee to deliver messages in the face of all possible difficulties.
Use of TCP
• Many frequently used services run over TCP connections, with reserved port numbers.
These include the following:
• HTTP: The Hypertext Transfer Protocol is used for communication between web
browsers and web servers
• FTP: The File Transfer Protocol allows directories on a remote computer to be browsed
and files to be transferred from one computer to another over a connection.
• SMTP: The Simple Mail Transfer Protocol is used to send mail between computers.
Java API for TCP streams
Its accept method gets a connect request from the queue or, if the queue is
empty, blocks until one arrives.
• Socket: This class is for use by a pair of processes with a connection. The
client uses a constructor to create a socket, specifying the DNS hostname
and port of a server.
• This constructor not only creates a socket associated with a local port but
also connects it to the specified remote computer and port number.