{"id":23536578,"url":"https://github.com/thesupercd/server_in_c","last_synced_at":"2025-05-14T23:09:02.431Z","repository":{"id":269255577,"uuid":"900619361","full_name":"TheSUPERCD/Server_in_C","owner":"TheSUPERCD","description":"A basic implementation of a daemonizable FTP server written in pure C. Also includes a client module that runs independently, with the ability to connect multiple unique instances of itself to the server to offload compute-heavy and parallelizable matrix problems to it.","archived":false,"fork":false,"pushed_at":"2024-12-24T07:57:04.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T06:45:17.750Z","etag":null,"topics":["c","ftp-server","gauss-jordan-elimination","kmeans-clustering","matrix-inversion","parallel-processing","pthreads","server","socket","socket-programming"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheSUPERCD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-12-09T06:44:31.000Z","updated_at":"2024-12-24T07:57:07.000Z","dependencies_parsed_at":"2024-12-22T07:27:44.603Z","dependency_job_id":"43673b35-3dcf-4ede-8cf6-01a246c13e7d","html_url":"https://github.com/TheSUPERCD/Server_in_C","commit_stats":null,"previous_names":["thesupercd/server_in_c"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FServer_in_C","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FServer_in_C/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FServer_in_C/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FServer_in_C/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheSUPERCD","download_url":"https://codeload.github.com/TheSUPERCD/Server_in_C/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243365,"owners_count":22038046,"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","ftp-server","gauss-jordan-elimination","kmeans-clustering","matrix-inversion","parallel-processing","pthreads","server","socket","socket-programming"],"created_at":"2024-12-26T02:29:30.141Z","updated_at":"2025-05-14T23:08:57.424Z","avatar_url":"https://github.com/TheSUPERCD.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n`Server_in_C` is a server-client application written purely in C, and designed to handle multiple client connections simultaneously. The server uses sockets for network communication and supports parallel processing of requests using `fork()` to spawn a new process for each independent client. This demo-server handles any client-side requests asking for a solution to numerical matrix-inversion and k-means clustering problems.\n\n## Features\n- **Multiple Client Connections:** The server can handle multiple clients simultaneously using the `fork()` system call, creating a new process for each client.\n- **Socket Communication:** Utilizes TCP sockets for reliable communication between the server and clients.\n- **Command Handling:** The server processes specific commands from clients for matrix inversion and k-means clustering.\n- **File Transfer:** Supports receiving data files from clients and sending result files back to clients.\n- **Logging:** Logs runtime errors and significant events to log files.\n- **Configurable Port:** The server can be started on any specified port, making it flexible for various network environments.\n\n## Requirements\n- GCC (GNU Compiler Collection)\n- Make\n- Linux environment (recommended)\n- `readline` library for client-side command-line interface\n\n## Compilation in a Linux/UNIX System\nTo compile and run the server and client, follow these steps:\n\n1. Clone the repository:\n   ```sh\n   $ git clone https://github.com/TheSUPERCD/Server_in_C.git\n   ```\n\n2. Navigate to the project directory:\n   ```sh\n   $ cd Server_in_C\n   ```\n\n3. Compile the server and client using `make`:\n   ```sh\n   $ make\n   ```\n\n## Usage\n\n### Starting the Server\nTo start the server, run the following command:\n```sh\n$ ./server -p \u003cport\u003e\n```\nReplace `\u003cport\u003e` with the port number you want the server to listen on.\n\nExample:\n```sh\n$ ./server -p 8080\n```\n\n### Connecting with the Client\nTo start the client and connect to the server, run the following command:\n```sh\n$ ./client -ip \u003cserver_ip\u003e -p \u003cserver_port\u003e\n```\nReplace `\u003cserver_ip\u003e` with the server's IP address and `\u003cserver_port\u003e` with the port number the server is listening on.\n\nExample:\n```sh\n$ ./client -ip 127.0.0.1 -p 8080\n```\n\n### Client Interaction\nOnce connected, clients can send commands to the server via a command-line interface. The client supports history and auto-completion for ease of use.\n\n### Supported Commands\nThe server processes the following commands:\n\n- **Matrix Inversion (`matinvpar`):**\n  This command computes the inverse of a given matrix.\n\n  Usage:\n  ```sh\n  $ matinvpar -n \u003cmatrix_size\u003e -I \u003cinit_type\u003e -P \u003cprint_switch\u003e -m \u003cmax_randnum\u003e\n  ```\n  Example:\n  ```sh\n  $ matinvpar -n 4 -I fast -P 1 -m 10\n  ```\n\n- **K-Means Clustering (`kmeanspar`):**\n  This command performs k-means clustering on a dataset.\n\n  Usage:\n  ```sh\n  $ kmeanspar -f \u003cfile_path\u003e -k \u003cnum_clusters\u003e\n  ```\n  Example:\n  ```sh\n  $ kmeanspar -f ./data/kmeans-data.txt -k 3\n  ```\n  The client will then send the data file to the server.\n\n- **Shutdown:**\n  This command gracefully shuts down the server process auto-spawned for the client.\n\n  Usage:\n  ```sh\n  $ shutdown\n  ```\n\n### Server Options\n- **-h:** Print the help message.\n- **-p port:** Listen on the specified port number (defaults to port 8080).\n- **-d:** Run as a daemon.\n- **-s strategy:** Specify the request handling strategy (only the `fork` strategy is implemented, the program defaults to this setting).\n\nExample:\n```sh\n$ ./server -p 8080 -s fork\n```\n\n### Client Options\n- **-h:** Print the help message.\n- **-ip server_ip:** Specify the server IP address (defaults to localhost ip).\n- **-p server_port:** Specify the server port number (defaults to port 8080).\n\nExample:\n```sh\n$ ./client -ip 127.0.0.1 -p 8080\n```\n\n## Acknowledgments\n- Thanks to **Microsoft** and **GitHub Copilot** for providing a great template for this `README.md` file.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesupercd%2Fserver_in_c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthesupercd%2Fserver_in_c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesupercd%2Fserver_in_c/lists"}