2161CS136 Distributed Systems: Unit II Process and Distributed Objects Lecture No.10 Interprocess Communication
2161CS136 Distributed Systems: Unit II Process and Distributed Objects Lecture No.10 Interprocess Communication
2161CS136
DISTRIBUTED SYSTEMS
Unit II Process and Distributed Objects
Lecture No.10 Interprocess Communication
School of Computing
Vel Tech Rangarajan Dr. Sagunthala R&D Institute of
Science and Technology
Interprocess communication
Learning objective:
• These messages are called datagrams. In the Java and UNIX APIs, the
sender specifies the destination using a socket – an indirect reference to a
particular port used by the destination process at a destination computer.
• The application program interface to TCP provides the abstraction of a two-
way stream between pairs of processes.
• 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
• In this section, we discuss the general characteristics of interprocess
communication and then discuss the Internet protocols as an example,
explaining how programmers can use them, either by means of UDP
messages or through TCP streams.
The characteristics of interprocess
communication
• Message passing between a pair of processes can be supported by two
message communication operations, send and receive, defined in terms of
destinations and messages.
• Whenever a send is issued the sending process (or thread) is blocked until the
corresponding receive is issued.
• Whenever a receive is issued by a process (or thread), it blocks until a message arrives.
• In the asynchronous form of communication, the use of the send operation is
nonblocking in that the sending process is allowed to proceed as soon as the message
has been copied to a local buffer, and the transmission of the message proceeds in
parallel with the sending process.
• The receive operation can have blocking and non-blocking variants.
• In the non-blocking variant, the receiving process proceeds with its program after
issuing a receive operation, which provides a buffer to be filled in the background,but it
must separately receive notification that its buffer has been filled, by polling or
interrupt.
Message destinations
• Messages are sent to (Internet address, local port) pairs.
• Processes may use multiple ports to receive messages. Any process that
knows the number of a port can send a message to it.
• If the client uses a fixed Internet address to refer to a service, then that
service must always run on the same computer for its address to remain
valid.
Reliability
• Reliability defines reliable communication in terms of validity and integrity.
2161CS136
DISTRIBUTED SYSTEMS
Unit II Process and Distributed Objects
Lecture No.11 Sockets and UDP
School of Computing
Vel Tech Rangarajan Dr. Sagunthala R&D Institute of
Science and Technology
Socket
• Both forms of communication (UDP and TCP) use the socket abstraction,
which provides an endpoint for communication between processes.
• Sockets originate from BSD UNIX but are also present in most other
versions of UNIX, including Linux as well as Windows and the Macintosh
OS.
• Processes may use the same socket for sending and receiving messages.
• Each computerhas a large number (216 ) of possible port numbers for use by
local processes for receiving messages.
• Any process may make use of multiple ports to receive messages but a
process cannot share ports with other processes on the same computer.
However, any number of processes may send messages to the same port.
Each socket is associated with a particular protocol – either UDP or TCP.
Java API for Internet addresses
• As the IP packets underlying UDP and TCP are sent to Internet addresses,
Java provides a class, InetAddress, that represents Internet addresses.
• For example, to get an object representing the Internet address of the host
whose DNS name is bruno.dcs.qmul.ac.uk, use:
• A server will bind its socket to a server port – one that it makes known to
clients so that they can send messages to it.
• A client binds its socket to any free local port. The receive method returns the
Internet address and port of the sender, in addition to the message, allowing the
recipient to send a reply.
Issues relating to datagram
communication
• Message size
- The receiving process needs to specify an array of bytes of a particular size
in which to receive a message.
- If the message is too big for the array, it is truncated on arrival.
• Blocking
• Timeouts:
- The receive that blocks forever is suitable for use by a server that is waiting
to receive requests from its clients.