How Sockets can be used to write client-server applications using a connection-oriented client-server technique?

Answer

Sockets can be used to write client-server applications using a connection-oriented client-server technique. Some characteristics of this technique include:

* The server can handle multiple client requests for connection and service.
* The server responds to any one client's request independently of all other clients.
* A client knows how to establish a connection with the server. 

The client-server connection, when established, remains in existence until either the client or the server explicitly breaks it, much like a trouble-free telephone call. The socket used for this connection is called a connection-oriented socket.
The socket type is specified as SOCK_STREAM. As a result, the process receiving a message processes that message by the following rules:

* The data transmitted has no boundaries.
* All bytes in a received message must be read before the next message can be processed.
* Bytes in a received message can be read in a loop program control structure since no data bytes are discarded.
* The server will usually fork() a child process upon establishment of a client connection.
* This child server process is designed to communicate with exactly one client process.
* The child server process performs the requested service for its connected client.
* The child server process terminates when the service request has been completed. 

Functions listen() and accept() enable the server to listen for service requests. read() and write() may be used by client and server to send/receive messages; send() and recv() may also be used. 

All sockets Questions

Ask your interview questions on sockets

Write Your comment or Questions if you want the answers on sockets from sockets Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---