0% found this document useful (0 votes)
54 views

6- Communication in Client Server System

Uploaded by

abdullahzahidhp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

6- Communication in Client Server System

Uploaded by

abdullahzahidhp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

1

CSC351-Operating System
Week-3 Lecture-6
Semester 5
2

➢ Process concept
➢ Operations on
Preamble Processes
(Past lesson ➢ Inter process
Communication
brief)

Lahore Garrison University


Technique for Communication in 3
Client- Server System

 Client/Server communication involves two components, namely a client and a


server. They are usually multiple clients in communication with a single server.
The clients send requests to the server and the server responds to the client
requests.
There are three main methods to client/server communication.
 Sockets
 Remote Procedure Calls (RPCs)
 Pipes

Lahore Garrison University


4
Sockets

 Used for communication in Client-Server Systems


 A socket is one endpoint of a two-way communication
 A pair of processes communicating over a network employ a pair of sockets-
one for each process
 A socket is identified by an IP address concatenated with a port number
 The server waits for incoming client request by listening to a specified port.
Once a request is received, the server accepts a connection from the client
socket to complete the connection.

Lahore Garrison University


5
Sockets

 Servers implementing specific services (such as telnet, ftp, and http)


listen to well-known ports
 (a telnet server listens to port 23, an ftp server listens to port 21, and a
web, or http, server listens to port 80).
 All ports below 1024 are considered well known; we can use them to
implement standard services.

Lahore Garrison University


6
Communication using
Sockets

Lahore Garrison University


7
Remote Procedure Calls (RPC)

 Remote Procedure Call (RPC) is a protocol that one program can use to
request a service from a program located in another computer on a
network without having to understand the network’s details,
 A remote procedure call is also known as a subroutine call or a function
call.
 It is similar in many respects to the IPC mechanism.
 However, because we are dealing with an environment in which the processes
are executing on separate systems, we must use a message-based
communication scheme to provide remote service.

Lahore Garrison University


8
Remote Procedure Calls (RPC)

 In contrast to the IPC facility, the messages exchanged in RPC communication


are well structured are thus no longer just packets of data.
 Each message is addressed to an RPC daemon(a program which is always
listening) listening to a part on the remote system, and each contains an
identifier of the function to execute and the parameters to pass to that
function.
 The function is then executed as requested, and any output is sent back to the
requester in a separate message.

Lahore Garrison University


9
Elements of RPC mechanism
implementation

 Client
 Client Stub
 RPC Runtime
 Server Stub
 Server

Lahore Garrison University


10
Remote Procedure Calls (RPC)

Lahore Garrison University


11
Semantics of RPCs

 The RPC system hides the details that allow communication to take place
by providing a stub on the client side.
 Typically, a separate stub exists for each separate remote procedure
 When the client invokes a remote procedure, the RPC system calls the
appropriate stub, passing it the parameters provided to the remote
procedure. This stub locates the port on the server and marshals the
parameters.
 Parameter marshalling involves packaging the parameters into a form
that can be transmitted over a network
 The stub then transmits a message to the server using message passing
 A similar stub on the server side receives this message and invokes the
procedure on the server
 If necessary, return values are passed back to the client using the same
technique
Lahore Garrison University
12
Pipes

 Pipe is a communication medium between two or more related or


interrelated processes
 It can be either within one process or a communication between the child
and the parent processes
 Communication is achieved by one process writing into the pipe and other
reading from the pipe

Lahore Garrison University


13
Issues

 In implementing a pipe, four issues must be considered


1. Unidirectional or Bidirectional communication?
2. Is bidirectional communication half-duplex or full-duplex?
3. Must a relationship such as parent-child exist between the processes?
4. Can pipes communicate over a network, or only on the same machine?

Lahore Garrison University


14
Ordinary Pipes

 ordinary pipes are unidirectional, allowing only one-way communication-


Ordinary pipes allow two processes to communicate in standard producer–
consumer fashion: the producer writes to one end of the pipe (the write-
end) and the consumer reads from the other end (the read-end).

If two-way communication is required, two pipes must be used, with each pipe
sending data in a different direction.

Lahore Garrison University


15
File descriptors for an ordinary
pipe.

 On UNIX systems, ordinary pipes are constructed using the function pipe(int
fd[]) This function creates a pipe that is accessed through the int fd[]
file descriptors: fd[0] is the read-end of the pipe, and fd[1] is the write-end.

Lahore Garrison University


16
Ordinary Pipes

• UNIX treats a pipe as a special type of file. Thus, pipes can


be accessed using ordinary read() and write() system calls.
• An ordinary pipe cannot be accessed from outside the process that created it.
• Typically, a parent process creates a pipe and uses it to communicate with a
child process that it creates via fork().
• A child process inherits open files from its parent. Since a pipe is a special type
of file, the child inherits the pipe from its parent process.

Lahore Garrison University


17
Named Pipes

 Named pipes provide a much more powerful communication tool.


Communication can be bidirectional, and no parent–child relationship is
required.
 Once a named pipe is established, several processes can use it for
communication. In fact, in a typical scenario, a named pipe has several writers.
Additionally, named pipes continue to exist after communicating processes have
finished.
 Named pipes are referred to as FIFOs in UNIX systems. Once created,
they appear as typical files in the file system. A FIFO is created with the
mkfifo() system call and manipulated with the ordinary open(), read(),
write(), and close() system calls. It will continue to exist until it is explicitly
deleted from the file system.

Lahore Garrison University


18
Half-duplex and Full
duplex Transmission-

 Although FIFOs allow bidirectional communication, only half-duplex


transmission is permitted.
 If data must travel in both directions, two FIFOs are typically used.

Lahore Garrison University


19
Reference

 To cover this topics , different reference material has


been used for consultation.
 Operating systems concept by Abraham siberchatz
edition 9
 Tutorialspoint.com
 Google.com

Lahore Garrison University

You might also like