0% found this document useful (0 votes)
29 views

Prepared By: Jay K Shrotriya Aim: Simple Client Server Program

This document discusses the primitives used for internet programming including SOCKET, BIND, LISTEN, ACCEPT, CONNECT, SEND, RECEIVE, and CLOSE. It explains that servers first create a socket, bind an address to the socket, listen for connections, and accept connections using those primitives. Clients create a socket and connect to the server. Data can then be sent and received before both sides close the connection.

Uploaded by

Jay Shrotriya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Prepared By: Jay K Shrotriya Aim: Simple Client Server Program

This document discusses the primitives used for internet programming including SOCKET, BIND, LISTEN, ACCEPT, CONNECT, SEND, RECEIVE, and CLOSE. It explains that servers first create a socket, bind an address to the socket, listen for connections, and accept connections using those primitives. Clients create a socket and connect to the server. Data can then be sent and received before both sides close the connection.

Uploaded by

Jay Shrotriya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Prepared By: Jay K Shrotriya

Aim: Simple Client Server Program


Theory:
The following are the primitives widely used for internet Programming.
Primitive Meaning
SOCKET Create a new connection end point.
BIND Attach a local address to a socket.
LISTEN Announce willingness to accept connections, give queue sequence.
ACCEPT Block the caller until the connection attempt arrives.
CONNECT Actively attempt to establish a connection.
SEND Send some data over the connection.
RECEIVE Receive some data over the connection.
CLOSE Close the connection.

The first four primitives in the list are executed in that order by servers. The SOCKET primitive
creates a new end point and allocates table space for it within the transport entry. The parameters of the
call specify the addressing format to be used, the type of service desired and the protocol. A successful
SOCKET call returns ordinary file descriptor for use in succeeding calls, the same way an open call does.
Newly created sockets do not have a network address. 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 address,
whereas others dont care.
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, LISTEN call is a blocking call.
To block waiting for an incoming connection, the server executes an ACCEPT primitive. When a
TPDU 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 new connection on the original
socket, ACCEPT returns a normal file descriptor, which can be used for reading and writing in the
standard way, the same as for files.
At 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, the client process is unblocked and the
connection is established. Both sides can now use SEND and RECV are required.
Connection release with the sockets is symmetric. When both sides have executed the CLOSE
primitive, then the sockets are closed and the connection is released.

You might also like