Client–Server Communication Using Socket
- Get link
- X
- Other Apps
Client–Server Communication Using Socket
In the client-server paradigm, communication takes place between two application programs called processes:
- Client Process → sends a request for a service
- Server Process → waits for requests, processes them, and sends responses
The server runs continuously and waits for clients, while the client runs only when service is needed.
Several APIs have been designed for communication. Three among them are common: socket interface, Transport Layer Interface (TLI), and STREAM.We will focus on socket only
Socket Interface
To enable communication between client and server processes, the operating system provides an Application Programming Interface (API) called a socket interface.
A socket is an abstraction or data structure created by an application program for communication through the network.
It acts like a communication endpoint between two processes.
Communication Flow
- The client sends a request through its socket.
- The request travels through the TCP/IP layers and the Internet.
- The server receives the request through its socket.
- The server processes the request and sends back a response through the socket.
Thus, communication at the application layer is actually socket-to-socket communication.
Socket Communication
Client Process ←→ Client Socket ←→ Internet ←→ Server Socket ←→ Server Process
The client assumes the socket delivers the request to the server, while the server assumes the socket receives requests from clients.

Socket Address
For communication, each socket needs an address called a socket address.
A socket address consists of:
| Component | Description |
|---|---|
| IP Address | Identifies the computer in the Internet |
| Port Number | Identifies the specific application process |
Socket Address Format
Socket Address = IP Address + Port Number
Example:
- IP Address → identifies the host machine
- Port Number → identifies services such as HTTP, FTP, etc.
Server Socket Address
The server requires:
1. Local Socket Address
- Known when the server starts
-
Contains:
- Server IP address
- Well-known port number (e.g., HTTP uses port 80)
2. Remote Socket Address
- Obtained when a client connects
- Changes for different clients
Client Socket Address
The client also needs:
1. Local Socket Address
- Assigned temporarily by the operating system
- Uses an ephemeral (temporary) port number
2. Remote Socket Address
-
Contains:
- Server IP address
- Server port number
The client may obtain the server IP using DNS (Domain Name System).
Services Used by Sockets
Sockets use transport-layer protocols for communication:
| Protocol | Features |
|---|---|
| UDP ( User Datagram Protocol) | Connectionless, fast, unreliable |
| TCP( Transmission Control Protocol) | Connection-oriented, reliable |
| SCTP(Stream Control Transmission Protocol) | Reliable and message-oriented |
Summary
- The client-server paradigm uses client and server processes.
- Communication occurs through sockets.
- A socket acts as an endpoint for sending and receiving data.
- Each socket is identified by an IP address and port number.
- Sockets use transport protocols such as TCP, UDP, or SCTP for communication.
- Get link
- X
- Other Apps


Comments
Post a Comment