0
4.2kviews
Explain Berkely sockets
1 Answer
0
59views

Sockets were first released as part of the Berkeley UNIX 4.2BSD software distribution in 1983. The primitives are now widely used for Internet programming on many operating systems, especially UNIX-based systems, and there is a socket-style API for Windows called ‘‘winsock.’’ The primitives are listed below:

enter image description here

  • The first four primitives in the list are executed in that order by servers. The SOCKET primitive creates a new endpoint and allocates table space for it within the transport entity. The parameters of the call specify the addressing format to be used, the type of service desired (e.g., reliable byte stream), and the protocol.
  • A successful SOCKET call returns an ordinary file descriptor for use in succeeding calls, the same way an OPEN call on a file does.
  • Newly created sockets do not have network addresses. These are assigned using the BIND primitive. Once a server has bound an address to a socket, remote clients can connect to it. The reason for not having the SOCKET call create an address directly is that some processes care about their addresses (e.g., they have been using the same address for years and everyone knows this address), whereas others do not.
  • Next comes the LISTEN call, which allocates space to queue incoming calls for the case that several clients try to connect at the same time. In the socket model LISTEN is not a blocking call. To block waiting for an incoming connection, the server executes an ACCEPT primitive.
  • When a segment asking for a connection arrives, the transport entity creates a new socket with the same properties as the original one and returns a file descriptor for it. The server can then fork off a process or thread to handle the connection on the new socket and go back to waiting for the next connection on the original socket.
  • ACCEPT returns a file descriptor, which can be used for reading and writing in the standard way, the same as for files.

    At the client side too, a socket must first be created using the SOCKET primitive, but BIND is not required since the address used does not matter to the server. The CONNECT primitive blocks the caller and actively starts the connection process. When it completes (i.e., when the appropriate segment is received from the server), the client process is unblocked and the connection is established. Both sides can now use SEND and RECEIVE to transmit and receive data over the full-duplex connection. The standard UNIX READ and WRITE system calls can also be used if none of the special options of SEND and RECEIVE are required.

  • Connection release with sockets is symmetric. When both sides have executed a CLOSE primitive, the connection is released.

    Sockets have proved tremendously popular and are the de facto standard for abstracting transport services to applications.

Please log in to add an answer.