0
3.1kviews
Explain Berkley API.
1 Answer
0
31views

An application programming interface (API) allows the application programs such as web browser or TELNET to access resources through an interface which is predefined. One of the most popular API is Berkeley socket interface. With the help of the socket mechanism, a programmer can write an application program easily without worrying about the underlying networking details.

Sockets:

The socket interface was originally based on UNIX. It defines a set of system calls or procedure. The communication structure that we need in socket programming is called as socket. A socket acts as an end point. Two process can communicate if and only if they have a socket at each end. One of the applications operates the server and the other one as client. The server works as a provider while the client acts as the receiver. The server waits passively until a client requires a service.

enter image description here

Types of services:

The socket mechanism can provide two types of services to the applications: 1. Connection oriented 2. Connectionless.

1. Connection oriented: For the connection oriented mode, an application has to be first established to a connection to another network before initializing any communication. After establishing a connection, the data transfer will take place and after transferring all the data the establishment is released. Connection oriented mode provides a reliable data transfer. The figure demonstrates the socket calls for connection oriented mode. The server first carries out a passive open as follows:

  • A TCP socket is created by using the socket call.
  • The bind call will then bind the well known port number of the server socket.
  • The socket is converted into a listening socket that can accept incoming connection from client by using the listen call.
  • Then finally the accept call will put the server in the blocking state on sleep mode until it receives a connect request from the client.

The client carries out an active open.

  • Socket creates call a socket on the client side.
  • Then the connect calls tries to establish a TCP connection to the server with the specified destination socket address.
  • After establishing the TCP connection, the accept function at the server gets activated and returns the descriptor for the given connection.

2. Connectionless mode:

  • In this mode it is not necessary to establish a connection prior to sending the data. An application can immediately start sending the data.
  • Thus the set up overheads are avoided in this mode. But the cost required to be paid is that the sending application may waste in sending the data when the receiving application is not ready to accept it.
  • Moreover the data may not arrive end if the network decides to discard it.
  • Another disadvantage is that the received data may not have the same order as that of the transmitted data.
  • The connectionless mode does not ensure a reliable data transfer shows the socket calls for the connectionless mode.
Please log in to add an answer.