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

TCP Client Server

TCP client server

Uploaded by

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

TCP Client Server

TCP client server

Uploaded by

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

Create a New Project for the Server

1. Open Code::Blocks.
2. Create New Project: Go to File -> New -> Project...
3. Select Console Application: Choose Console Application and click Go.
4. Choose Language: Select C and click Next.
5. Enter Project Details: Title it (e.g., "TCPServer"), select a location, and
click Finish.
6. Add Source File: In the Project Explorer, find the Sources folder, right-click
it, and select Add file....
7. Create New C File: Name it (e.g., server.c) and paste your TCP server code into
this file.
8. Save Changes: Press Ctrl + S.

Create a New Project for the Client


1. Repeat Steps 2-9 to create a project for the client (e.g., "TCPClient").
2. Paste Client Code: In your new file (e.g., client.c), paste the TCP client code.
3. Save Changes: Press Ctrl + S.

Link Against Winsock Library for both projects


1. Open Build Options: Go to the Project menu. Right-click on TCPServer and select
Build options.
2. Select Your Project: Click on your project name in the left panel.
3. Linker Settings Tab: Navigate to the Linker settings tab.
4. Add Winsock Library: In the Other linker options box, type -lws2_32.
5. Repeat for Each Configuration: Click on Debug and add -lws2_32. Do the same for
Release.
6. Save Changes: Click OK to save.
7. Rebuild Your Project: Click the yellow gear icon (Build) or press F9.

Build the Projects


1. Build TCPServer: Click the build icon or press F9 to compile.
2. Build TCPClient: Repeat the build process for the client.
3. Check that executables are created in the specified path (server.exe and
client.exe).

Run the TCP Server and Client


1. Open Command Prompt: Start a Command Prompt window.
2. Navigate to Server Executable: Change to the directory where server.exe is
located.
3. Run Server: Type start cmd /k "path\to\your\server.exe" to open a new Command
Prompt for the server.
4. Repeat for Client: Use a similar command to run the client in a separate window.

Find Server IP Address


1. Get IP Address: In the Command Prompt where the server is running, type
ipconfig.
2. Copy IPv4 Address: Note the IPv4 address.

Performance Analysis Steps


1. Measure Latency: In the TCPClient Command Prompt, type ping <server-ip> to
measure round-trip time.
2. Analyze Path: Use tracert <server-ip> to see the route packets take to reach the
server.
3. Monitor Connections: Type netstat -an to view active connections and statistics.

You might also like