Project Name: Client Server Communication Using Threads And Sockets.
Scope: This project is used to setup communication between server and client. With the help of this we can send and receive data from one client to another or between server and client.
Description: We have done this project in phases -
Phase – I: One server One client
At the server end we have created one socket which will help to communicate with the client. After creating the socket using command “socket()”, we named it using command “bind()”. Naming the socket will give the easy access to the client as this socket will be visible to the client.
If we are performing this communication within the system/computer, then we will use AF_UNIX to name the socket.(Here we can give any alpha or alphanumeric name). Other wise, if we are establishing between two networks the we use AF_INET. In this we have to mention the port number and IP address of the server). We have used TCP/IP protocol for our project.
Note: we will never give name to the socket of client, we always give name to the socket of server which is visible to all the client.
Simultaneously, at the client end we have created a socket through which it will communicate with the server. After that client sent a request to the server to get connected using command “connect()”. At the server end, server will listen the request sent from the client using command “listen()” and it will create a queue. (Note: If in the mean time another client wants to connect with the server, the 2nd client request will go to the queue.) After getting the request from the client , server will accept the request using command “accept()”and this command will return a file descriptor (a stream) through which client will send and receive data to and from the server respectively.
At end of data transfer client will close the socket and simultaneously server will delete the stream connected to the particular client.
Phase – II: One server several clients
The procedure for this second phase is almost same as phase I. In the same way as mentioned above, we will create many clients which will send requests to the server to communicate simultaneously. Server will create a queue to manage the request .
Phase – III: One server several clients using threads
In this phase we have many clients who wants to communicate with the server. Every client will send request to the server, and at the server end queue is created (as explained above). One by one server will except the request and will assign the work to different functions. Here instead of calling different functions we have used concept of threads. Server will create threads on every receipt of request from the client end.
With the help of these threads the process time of the server is reduced as it is distributing its workload within threads.
Functionality:
1. This basic project will help to reduce the process timing of client. If client wants to process some data, it will send the raw data to the server and server will send back the processed output to the client.
2. Planning for phase IV. In this phase we will establish the link between different clients through one server. In this project clients will communicate with themselves or we can say these clients will share data with each other.