Anonymous

What Is Socket? Explain Its Fields And Types.

1

1 Answers

Shumaela Rana Profile
Shumaela Rana answered
The "communication structure" that we require in "socket programming" is a "socket". A "socket" acts like an end point. Two processes require a socket at both ends to correspond and communicate with each other. A "socket" can be defined in the "operating system" as a structure. In a basic version of a socket structure there are five fields which are listed below.
Family: protocol group is defined by this field. e.g. "IPv4", "IPv6", "UNIX domain protocols" etc.
Type: defines the type of a socket like "stream, packet, or raw socket".
Protocol: is usually set to zero for both TCP and UDP.
Local socket address: defines the "local socket address".
Remote socket address: defines the "remote socket address".
The "socket interface" defines 3 types of sockets: 1. stream socket, 2. the packet socket, 3. the raw socket.
Stream socket: it is intended to be used by "connection-oriented protocols" such as "TCP". "Tcp" uses a pair of stream sockets to connect and fix 1 application program to another across "the internet".
Datagram socket: it is intended to be used by "connectionless protocol" such as "UDP". "UDP" uses a pair of "datagram sockets" to throw a message from 1 application program to another across "the internet".
Raw Socket: a number of protocols for example "ICMP or OSPF" which directly uses these services of IP use neither "stream sockets" nor "datagram sockets". "Raw sockets" are intended for these types of applications.

Answer Question

Anonymous