0% found this document useful (0 votes)
6 views2 pages

Socket Programming Labs in Python

The document outlines a series of lab exercises focused on socket programming using Python, covering client basics, simple TCP server creation, and multithreading. Each lab includes objectives, tasks, and questions to deepen understanding of socket concepts and functionality. Key topics include TCP connections, message handling, and packet analysis using tools like Wireshark.

Uploaded by

waildayaeddine
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Socket Programming Labs in Python

The document outlines a series of lab exercises focused on socket programming using Python, covering client basics, simple TCP server creation, and multithreading. Each lab includes objectives, tasks, and questions to deepen understanding of socket concepts and functionality. Key topics include TCP connections, message handling, and packet analysis using tools like Wireshark.

Uploaded by

waildayaeddine
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

TP3 M1 RSD - Advanced Networks 1

Socket Programming Labs – Python Client/Server and Multithreading

Lab 1 — Introduction to Sockets (Client Basics)

Objectives
- Understand what a socket is.

- Create and connect to a TCP server.

- Send and receive simple text messages.

Tasks
- Create a TCP socket and connect to [Link].

- Send an HTTP GET request.

- Receive the first 1024 bytes and print the response.

Questions
- What is AF_INET vs SOCK_STREAM?

- What happens if the port is closed?

- Why do we use encode()?

Lab 2 — Simple TCP Server (One Client Only)

Objectives
- Create a server that listens on a port.

- Accept only one connection.

- Send and receive simple messages.

Tasks
- Bind to [Link]:5000 and listen.

- Accept one client and print 'Client connected'.

- Receive a message and reply 'Message received'.

Questions
- Why is accept() called once?
- What happens if another client tries to connect?

- Why loops are needed for multi-client servers?

Lab 3 — Multithreading TCP Server

Objectives
- Handle multiple clients simultaneously.

- Use threads to avoid blocking.

Tasks
- Listen on port 5000.

- Create a new thread for each client.

- Echo messages until client sends 'bye'.

Questions
- What problem does multithreading solve?

- Does a slow client block others?

- Draw the accept() threading diagram.

Lab 4 — Packet Capture and Analysis (Wireshark)

Objectives
- Visualize TCP handshake.

- Analyze client/server packets.

Tasks
- Run server and capture traffic.

- Find SYN, SYN/ACK, ACK.

- Observe data and FIN packets.

Questions
- Difference between TCP segment and application message?

- Why can messages be split?

You might also like