I explained an Interprocess communication (i.e. Pipe, named pipe) between two applications or process in system. You might be wondering if two applications available in different machines over the network (i.e. local PC or server), pipe or named pipe are communicated or not? Pipe or named pipe can communicate only those processes which are located in the same system. We can communicate with application which is located in different systems through new communication method named Socket.
Socket is the end point of two way communication link between two programs running on network. You can also communicate between two processes through socket on same machine but mostly it is used for communicating over network. Socket is supported by different operating systems like window, MAC, Linux, Unix etc.
Socket is usually interfaced by application programming interface (API) which is provided by operating system. API allows the program to use network socket and connect with another machine over the network.
Socket is used in server – client model application. Server is the process which responds upon request from client (i.e. local user PC). Socket is an end point communication of two applications. It is created on both sides of client and server for communicating together. Socket communicates over network by IP address and port number. IP address is numerical value assigned to each computer and device which uses the internet protocol for communication. Port is way to identify specific process to which an internet or other network message is forwarded when it arrives at server. There are different types of sockets. Stream socket is used for TCP connection and datagram socket is used for UDP connection. I will also explain server – client model for understanding how does socket work with server – client model.
Server – Client model
Server-client model is the communication model for sharing the resource and provide the service to different machines. Server is the main system which provides resources and different kinds of services when client requests to use it.
Server – client model is communicated by Secure Socket Layer (SSL). SSL is computer networking protocol that manages server authentication. SSL provides the public and symmetric keys for secure communication between two machines over the internet like web, mail server or client PC or machine.
Fig. 1:Overview of Server-Client Model
Server Side
Server listens to the client request from different clients. Upon accepting the request, the server creates a socket for new client request. Socket creates by binding the port and address of client in server side. Server waits for sending response to client and then sends the response to accept the connection. After connection, server and client both are able to share data.
Fig. 2: Overview of Server-Client Communication
Client Side
Client can also bind the local port number and address which is used during communication. It sends the request to server. After that, client will wait and receive the response from server. Now client is able to transfer data with server. Server closes the socket and disconnects the connection with client if timeout occurrs.
Transmission Protocols of Socket
There are basically two transmission protocols supported by socket:
1) TCP/IP
2) UDP
TCP/IP
TCP/IP (Transmission Control Protocol) is connection oriented protocol. Message or data is transferred from one computer to another over the internet. TCP is heavy weight protocol. It provides flow of data control, acknowledgment, guarantee of arrived of message and error checking.
UDP
UDP (User Datagram Protocol) is connection less protocol. It also transfers the message or data from one computer to another with end point connection relation which means it is not connection oriented like TCP/IP rather a light weight protocol and faster than TCP/IP. It does not provide acknowledgement, flow of data control and guarantee for the arrival of message.
We can create the socket in Linux and also develop the client server model using TCP/IP or UDP protocol. I will explain how to create socket and socket ( ) system call in the next tutorial.
Filed Under: Tutorials
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.