The Sockets are generally used for inter-process communication. Socket is one end inter process communication channel. But most of them use client server module for communicating between the two systems. The Server request for the information. The client must know the address of d server but there is no need of knowing the client address for server. By establishing connection they can send and receive the information. For this process of communication both the process establishes the own sockets.

Steps involved in construction of socket on client side:

  • Create the socket with socket () of system call.
  • All socket addresses are connected to server by Connect () System call.
  • For sending and receiving the data Read () and Write () system calls are used.

Steps involved in construction of socket on Server side:

  • Create the socket with socket () of system call.
  • The socket is bind to a system address by Bind () system call.
  • The server socket for connection need host name on the internet.
  • The connections are listened by Listen () system call.
  • The connection is accepted by Accept () of system call.
  • The last process is send and receive data.

Socket types:

The communication between the two sockets is possible only if the two sockets are of same type. The socket should specify the address domain and socket type for communication. There are two widely used domains UNIX domain and INTERNET domain. In UNIX domain two common file system names is shared.

And coming to internet two hosts can communicate with each other easily. The address of socket in UNIX domain is character string in INTERNET it is internet address of host machine that is IP address which is 32 bit code. For each socket a port number is required which is 16 bit unsigned integers. There are two most widely used sockets called stream sockets datagram sockets. Stream sockets read data as continuous stream of characters coming to datagram as a block of messages at once.

Download  Sockets Tutorial Report for Computer Science Students.