{"id":25089553,"url":"https://github.com/witsey/http-server","last_synced_at":"2025-04-01T17:23:03.196Z","repository":{"id":276064527,"uuid":"926982773","full_name":"witsey/HTTP-server","owner":"witsey","description":"This is a simple TCP server implemented in C for Windows using the Winsock library. This project aims to provide a foundational understanding of socket programming and network communication in C.","archived":false,"fork":false,"pushed_at":"2025-02-06T03:59:03.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T04:28:35.812Z","etag":null,"topics":["c","http-server","server","web","web-ser"],"latest_commit_sha":null,"homepage":"","language":"C","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/witsey.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":"2025-02-04T07:44:07.000Z","updated_at":"2025-02-06T03:59:07.000Z","dependencies_parsed_at":"2025-02-06T04:38:51.171Z","dependency_job_id":null,"html_url":"https://github.com/witsey/HTTP-server","commit_stats":null,"previous_names":["witsey/http-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/witsey%2FHTTP-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/witsey%2FHTTP-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/witsey%2FHTTP-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/witsey%2FHTTP-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/witsey","download_url":"https://codeload.github.com/witsey/HTTP-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237634577,"owners_count":19342067,"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":["c","http-server","server","web","web-ser"],"created_at":"2025-02-07T11:17:48.188Z","updated_at":"2025-02-07T11:17:50.320Z","avatar_url":"https://github.com/witsey.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple TCP Server in C (Windows)\n\n## Overview\nThis project is a basic TCP server written in C using the Winsock library. The server listens for incoming connections on **port 8080** and sends a simple response to clients. This is part of a learning journey to understand **socket programming** and **network communication** in C.\n\n## Features\n✅ Creates a TCP socket using `socket()`  \n✅ Binds the socket to an IP and port using `bind()`  \n✅ Listens for incoming connections using `listen()`  \n✅ Accepts client connections using `accept()`  \n✅ Sends a basic HTTP response to the client  \n\n## How to Run\n### Prerequisites\n- Windows OS\n- MinGW or MSVC (for compiling C code)\n- Git (optional, for version control)\n\n### Steps\n1. **Clone the Repository** (if applicable)\n   ```sh\n   git clone \u003cyour-repo-url\u003e\n   cd \u003cyour-repo-folder\u003e\n   ```\n2. **Compile the Code**\n   Using MinGW:\n   ```sh\n   gcc server.c -o server.exe -lws2_32\n   ```\n   Using MSVC:\n   ```sh\n   cl server.c /link ws2_32.lib\n   ```\n3. **Run the Server**\n   ```sh\n   server.exe\n   ```\n4. **Test the Server**\n   - Open a browser and visit: `http://127.0.0.1:8080`\n   - You should see `Hello, world!` displayed.\n\n## How It Works\nThis program follows the standard steps for creating a server:\n1. **Initialize Winsock** using `WSAStartup()`\n2. **Create a socket** using `socket(AF_INET, SOCK_STREAM, 0)`\n3. **Configure socket options** with `setsockopt()`\n4. **Define the server address** (`sockaddr_in` structure)\n5. **Bind the socket** to the address using `bind()`\n6. **Start listening** for connections using `listen()`\n7. **Accept incoming connections** using `accept()`\n8. **Send a response** to the client (`send()`) before closing the connection\n9. **Cleanup** using `closesocket()` and `WSACleanup()`\n\n## Next Steps\n🚀 Implement **handling multiple clients**  \n🚀 Add **better error handling \u0026 logging**  \n🚀 Serve **static files (HTML, CSS, JS)**  \n🚀 Make the server accessible over a network  \n\n## Contribution\nIf you want to contribute, feel free to fork the repo and submit a pull request. Feedback and improvements are welcome!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwitsey%2Fhttp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwitsey%2Fhttp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwitsey%2Fhttp-server/lists"}