You are inside a passionate computer engineer's lab...
Proceed at your own risk...

Look for something inside my Lab...

Client/Server network communication using socket

Task:
  1. Make a server program which listens for connection from multiple clients. It receives data from the client and prints it on the standard output.
  2. Make a client program which connects to the given server. It sends data to it.
Notes:
  • The clients are served in parallel, each connected client has a thread associated. There is no explicit limit on the number of connected clients.
  • The client is portable on Linux and Windows. It uses Winsock 2 API on Windows.
  • The server runs only on Linux because it uses the pthread API.
  • The connection protocol can use virtually any protocol (including IPv4 and IPv6).
  • The server uses the port 20200 by default. This can be changed in command line arguments.
  • The client uses port 20200 by default, and tries to connect to a server running on localhost. This can be changed in command line arguments.
Source package:
The source package contains the client and server sources. If you have Linux, extract its contents and run make. It will compile both of them. Once done, you will find a new directory called bin, inside which another called debug, inside which you find two executable files: the server nsa_server and the client nsa_client.
Here is a link for download: nsa.tar.gz

Wireshark screenshots:
Using wireshark, we watched the network activity between the client and server. We made a local connection (on the localhost).


The network activity is described as follows:
  1. The first 3 frames indicate connection requests (SYN) from the client and the server along with connection acknowledgements.
  2. The following 2 frames indicate that the client sent data to the server which acknowledged it. The data was "HELLO!!!".
  3. The last 3 frames indicate connection closing by both client and server along with the respective acknowledgements.

No comments:

Post a Comment