{"id":25155429,"url":"https://github.com/ranimeshehata/socket-programming","last_synced_at":"2025-06-28T16:35:32.368Z","repository":{"id":262333641,"uuid":"882054817","full_name":"ranimeshehata/Socket-Programming","owner":"ranimeshehata","description":"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.","archived":false,"fork":false,"pushed_at":"2024-11-11T21:17:29.000Z","size":1108,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T00:52:59.678Z","etag":null,"topics":["client-server","get-post-method","networks","python-socket","socket-programming","timeout"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ranimeshehata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-01T19:30:10.000Z","updated_at":"2025-01-02T09:01:56.000Z","dependencies_parsed_at":"2024-11-11T22:20:18.559Z","dependency_job_id":null,"html_url":"https://github.com/ranimeshehata/Socket-Programming","commit_stats":null,"previous_names":["ranimeshehata/socket-programming"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FSocket-Programming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FSocket-Programming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FSocket-Programming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FSocket-Programming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ranimeshehata","download_url":"https://codeload.github.com/ranimeshehata/Socket-Programming/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246997766,"owners_count":20866686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-server","get-post-method","networks","python-socket","socket-programming","timeout"],"created_at":"2025-02-09T00:51:45.060Z","updated_at":"2025-04-03T11:40:25.534Z","avatar_url":"https://github.com/ranimeshehata.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Socket-Programming in Python\n\nThis 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. \n\n## Connections\n- Persistent connection is made between server and each client\n- Each connection runs on a separate thread.\n- Each connection has a dynamic timeout set by server, `timeout = max(5 seconds, 20 - current-number-of-connections)`\n- 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\n\n## Requests\nClients can send:\n- `GET` requests to get a certain file from the server\n- `POST` requests to send a file to the server\n## Responses\nThe server can respond with:\n- `200 OK` if the request was successful\n- `404 Not Found` if the requested file was not found\n\n**For GET requests, the server will send the file requested by the client. \nFor POST requests, the server will save the file sent by the client.**\n\n## Files Supported \nThe server can handle the following file types:\n- `.txt`\n- `.jpg`\n- `.png`\n- `.html`\n\n## How to run Server\n1. Default port: 8080\n    ```\n    python3 server/server.py\n    ```\n2. Commandline argument port\n    ```\n    python3 server/server.py 8089\n    ```\n\n## How to send Requests\n1. Client which asks for request every time\n    ```\n    python3 client/client.py \n    ```\n2. Client which parses file to send requests to server\n    ```\n    python3 client/client_parser.py hostname port\n    ```\n    Or use defaults, localhost and 8080:\n    ```\n    python3 client/client_parser.py\n    ```\n    \n## Testing\n 1. Bonus Test Cases\n    ```\n    http://localhost:8080/server/testServer.txt\n    ```\n    ```\n    http://localhost:8080/server/photoServer.jpg\n    ```\n    ```\n    http://localhost:8080/server/welcome.html\n    ```\n2. `client.py` tests\n    ```\n    GET server/testServer.txt\n    ```\n    ```\n    POST client/testClient.txt\n    ```\n    ```\n    GET server/photoServer.jpg\n    ```\n    ```\n    POST client/photoClient.jpg\n    ```\n    ```\n    GET server/welcome.html\n    ```\n### Notes\n`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.\n\n### Finally ... Welcome to our Server!\n![](./image.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franimeshehata%2Fsocket-programming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Franimeshehata%2Fsocket-programming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franimeshehata%2Fsocket-programming/lists"}