{"id":23395927,"url":"https://github.com/ghindea/tcp-udp-client-server-app","last_synced_at":"2025-09-09T06:34:48.786Z","repository":{"id":249642916,"uuid":"832084910","full_name":"Ghindea/TCP-UDP-Client-Server-App","owner":"Ghindea","description":"C++ Client-Server application for messages between TCP \u0026 UDP clients","archived":false,"fork":false,"pushed_at":"2024-07-22T10:40:51.000Z","size":615,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T13:38:58.986Z","etag":null,"topics":[],"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/Ghindea.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-07-22T10:20:13.000Z","updated_at":"2024-07-22T10:45:49.000Z","dependencies_parsed_at":"2024-07-22T13:05:36.865Z","dependency_job_id":null,"html_url":"https://github.com/Ghindea/TCP-UDP-Client-Server-App","commit_stats":null,"previous_names":["ghindea/tcp-udp-client-server-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghindea%2FTCP-UDP-Client-Server-App","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghindea%2FTCP-UDP-Client-Server-App/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghindea%2FTCP-UDP-Client-Server-App/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghindea%2FTCP-UDP-Client-Server-App/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ghindea","download_url":"https://codeload.github.com/Ghindea/TCP-UDP-Client-Server-App/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247888568,"owners_count":21013002,"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":[],"created_at":"2024-12-22T07:19:35.908Z","updated_at":"2025-04-08T17:19:43.575Z","avatar_url":"https://github.com/Ghindea.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SERVER-CLIENT APPLICATION WITH UDP AND TCP\n\nby: **_Daniel GHINDEA_** - 325CB\n\nMy homework implements a simple C++ application which allows UDP clients to\nconnect to a server that acts like a broker, communicating with TCP subscribers.\n\nSee the requirements [here](./Enunt_Tema_2_Protocoale_2023_2024.pdf)\n\n## Description\n\nThis project is designed to implement a server-client model where the server can handle requests from multiple subscribers. It includes a simple communication system where the `server` component processes incoming connections and interactions, while `subscriber` acts as the client that connects to and communicates with the server.\n\n## Features\n\n- **Server Implementation**: Handles incoming connections and processes client requests.\n- **Subscriber Client**: Connects to the server and sends requests based on user input.\n- **Modular Design**: Core functionalities are encapsulated in the `lib.h` header.\n\n### Building the Project\n\nTo build the server and the subscriber programs, you can use the provided `Makefile`:\n\n```bash\nmake\n```\n\nThis command compiles the `server` and `subscriber` programs and generates executable files.\n\n### Running the Application\n\nTo run the server program:\n```\n./server \u003cPORT\u003e\n```\n\nTo run the subscriber client in a separate terminal:\n```\n./subscriber \u003cID\u003e \u003cSERVER_IP\u003e \u003cSERVER_PORT\u003e\n```\n\nTo run all available tests:\n```\npython3 test.py\n```\n\nEnsure the server is running before starting the subscriber.\n\n### About TCP protocol\n- when server is launched it creates 3 sockets to communicate with STDIN, UDP clients \u0026 TCP clients\n- when client starts it creates a socket for TCP connection with the server through which the ID of the client is sent\n- to implement the multiplexation of connections the program uses poll\n- server-side uses a special structure to communicate with the TCP-client (`message_to_tcp`) which can transmit the message that came from udp to that client \u0026 a custom signal to transmit actions\n\n```cpp\nstruct message_to_tcp {\n    server_signal signal_from_server;\n    uint16_t recv_port;\n    char recv_ip[MAX_IP_LEN];\n    _udp_message_ udp_message;\n    string toString() {\n        string s = \"\";\n        s +=  udp_message.topic +\n                string(\" - \");\n        switch (udp_message.tip_date) {\n            case 0 : {s += \"INT - \"; break;}\n            case 1 : {s += \"SHORT_REAL - \"; break;}\n            case 2 : {s += \"FLOAT - \"; break;}\n            case 3 : {s += \"STRING - \";break;}\n        }\n        s += udp_message.content;\n        return s;\n    }\n};\n```\n- client-side uses another structure to communicate with the server (`message_to_server`) which can transmit data about the content that the client wants to see \u0026 also a custom signal to transmit actions\n\n```cpp\nstruct message_to_server {\n    server_signal signal_to_server;\n\n    char client_id[MAX_IP_LEN];\n    char topic[MAX_TOPIC_LEN];\n};\n```\n- the custom signal is represented by an enum which describes 4 possible actions\n\n```cpp\nenum server_signal {\n    SUBSCRIBE,\t\t// sent by tcp client to tell the server it wants to subscribe\n    UNSUBSCRIBE,\t// sent by tcp client to tell the server it wants to unsubscribe\n    NOTIFICATION,\t// sent by the server to tell the client it has a new notification\n    EXIT\t\t// sent by both of them to tell to the other one that it's is disconnecting\n};\n```\n\n**Note**: At the moment wilcards are not working.\n\nRESULTS\n```\ncompile...............................................passed\nserver_start..........................................passed\nc1_start..............................................passed\ndata_unsubscribed.....................................passed\nc1_subscribe_all......................................passed\ndata_subscribed.......................................passed\nc1_stop...............................................passed\nc1_restart............................................passed\ndata_no_clients.......................................passed\nsame_id...............................................passed\nc2_start..............................................passed\nc2_subscribe..........................................passed\nc2_stop...............................................passed\nserver_stop...........................................passed\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghindea%2Ftcp-udp-client-server-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghindea%2Ftcp-udp-client-server-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghindea%2Ftcp-udp-client-server-app/lists"}