This project is a simple implementation of a client-server model using Python's socket module. The server is able to handle multiple clients at once.
- Persistent connection is made between server and each client
- Each connection runs on a separate thread.
- Each connection has a dynamic timeout set by server,
timeout = max(5 seconds, 20 - current-number-of-connections)
- Server itself has
a timeout of 60 seconds of inactivity
, meaning if server doesb't get any requests for continuous 60 seconds it will shut down
Clients can send:
GET
requests to get a certain file from the serverPOST
requests to send a file to the server
The server can respond with:
200 OK
if the request was successful404 Not Found
if the requested file was not found
For GET requests, the server will send the file requested by the client. For POST requests, the server will save the file sent by the client.
The server can handle the following file types:
.txt
.jpg
.png
.html
- Default port: 8080
python3 server/server.py
- Commandline argument port
python3 server/server.py 8089
- Client which asks for request every time
python3 client/client.py
- Client which parses file to send requests to server
Or use defaults, localhost and 8080:
python3 client/client_parser.py hostname port
python3 client/client_parser.py
- Bonus Test Cases
http://localhost:8080/server/testServer.txt
http://localhost:8080/server/photoServer.jpg
http://localhost:8080/server/welcome.html
client.py
testsGET server/testServer.txt
POST client/testClient.txt
GET server/photoServer.jpg
POST client/photoClient.jpg
GET server/welcome.html
index.html
was changed because browsers load its favicon by default which leads to delay, so it was changed to welcome.html
to avoid confusion.