What is Socket?
The communication structure used in socket programming is called as socket. A socket acts as an end point . Two processes can communicate if and only if they have a socket at each end.
Socket Structure:-
Various fields in socket structure are as under:-
- Family: This field is used for defining the protocol group such as IPv4 or IPv6 , unix domain protocol etc.
- Type: Thus field is used for defining the type socket such as stream socket, packet socket, or raw socket.
- Protocol: This field is usually set to zero for TCP and UDP.
- Local Socket Address: It is used for defining the local socket address . This address is a contribution of local IP address and the port address of the local application program.
- Remote Socket Address: It is used for defining the remote socket address which is a combination of remote IP address and the port address of the remote application program.
Types Of Socket:-
There are following three types of socket:-
1. Stream Socket:-
This is designed for the connection oriented protocol such as TCP. The TCP uses a pair of stream sockets for connecting one application program to the other across the internet.
2. Datagram Socket:-
This type of socket is designed for the connectionless protocol such as UDP. UDP uses a pair of datagram socket for sending a message from one application program to another across the internet.
3. Raw Socket:-
Raw sockets are designed for the protocols like ICMP or OSPF, because these protocols do not use either stream packets or datagram packets.
What is Connectionless Iterative Server?
The server that uses UDP is usually connectionless iterativ . A server gets the request received in a packet from UDP , it processes the request and gives the response to UDP which is send to the client. The server does not pay attention to other packet . Thus, other packets are stored in a queue waiting for the service.
The functions of the server are as follows:-
- Create a socket: The server asks the operating system to create a socket.
- Bind: The server asks the operating system to enter information in the socket related to the server . This is called as binding the server socket.
- The server repeats the following steps for infinite number of times:
- Receive a request.
- The request is processed by the server.
- The response is sent to the client.
Click here for government certification in Information Technology
3 Comments. Leave new
Good job, Supreet!
Well written!
Informative