This repository contains implementations of various network programming problems using Python's socket library. The solutions cover different aspects of client-server communication, including file transfer, concurrency, remote computation, streaming, and chatting applications.
- Introduction
- Technologies Used
- Project Structure
- Problem Descriptions
- Setup Instructions
- Installation Requirements
- How to Run
- Examples
- Project Description
- Challenges Faced
- Future Enhancements
- Contributing
- License
- Author
This project demonstrates the use of Python for creating various network applications using sockets. The problems involve:
- Implementing file transfer using TCP and UDP sockets.
- Creating a concurrent file server capable of handling multiple clients using multithreading.
- Developing a remote calculator service for arithmetic operations.
- Implementing a streaming client-server application using connectionless sockets.
- Developing a single client-server chatting application using both TCP and UDP.
- Extending the single client-server chatting application to support multiple clients.
- Python 3.6+
- Socket Programming
- Multithreading
socket-programming-python/
├── problem1/ # File Transfer Protocol (FTP)
│ ├── tcp_server.py
│ ├── tcp_client.py
│ ├── udp_server.py
│ └── udp_client.py
├── problem2/ # Concurrent File Server
│ ├── server.py
│ └── client.py
├── problem3/ # Remote Calculator
│ ├── server.py
│ └── client.py
├── problem4/ # Streaming Client-Server Application
│ ├── server.py
│ └── client.py
├── problem5/ # Single Client-Server Chatting
│ ├── tcp_chat_server.py
│ ├── tcp_chat_client.py
│ ├── udp_chat_server.py
│ └── udp_chat_client.py
├── problem6/ # Multi-Client Chatting Application
│ ├── server.py
│ └── client.py
├── LICENSE.md
└── README.md
Description:
This solution implements a basic file transfer protocol using both TCP (connection-oriented) and UDP (connectionless) sockets. The client divides the file into chunks of 100 bytes and sends them to the server. The server acknowledges receipt of each chunk (for TCP). If the acknowledgment is not received within a timeout period, the client retransmits the chunk. For UDP, the file is sent as datagram packets without acknowledgment.
Description:
This solution implements a concurrent file server using multithreading. Each client request spawns a new thread, allowing multiple clients to request files simultaneously. The server reads the specified file and sends its contents to the client.
Description:
The remote calculator accepts two integers and an arithmetic operation (+, -, *, /, %) from the client. The server performs the operation and returns the result to the client.
Description:
The streaming client requests a multimedia file (audio or video) from the server. The server reads the file in chunks of random sizes (between 1000 and 2000 bytes) and sends them as datagram packets. The client receives the packets and plays the stream in real-time.
Description:
This solution implements a simple chatting application using both TCP (connection-oriented) and UDP (connectionless) sockets. The user at the client side can send messages by pressing "Enter". Each message must receive a reply before another message is sent.
Description:
This solution extends the single client-server chatting application to support multiple clients. The server handles each client in a separate thread, allowing multiple clients to chat with the server concurrently.