{"id":13732170,"url":"https://github.com/Krozark/cpp-Socket","last_synced_at":"2025-05-08T06:31:34.657Z","repository":{"id":8216137,"uuid":"9652389","full_name":"Krozark/cpp-Socket","owner":"Krozark","description":"Some class to help to construct client/server with soket and serilized datas.","archived":false,"fork":false,"pushed_at":"2016-01-22T09:25:26.000Z","size":4609,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-04T02:10:53.143Z","etag":null,"topics":["cpp11","socket"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"angular-ui/ui-grid","license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Krozark.png","metadata":{"files":{"readme":"README.md","changelog":"changelog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-24T16:26:20.000Z","updated_at":"2019-09-20T21:48:52.000Z","dependencies_parsed_at":"2022-09-04T05:00:32.154Z","dependency_job_id":null,"html_url":"https://github.com/Krozark/cpp-Socket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krozark%2Fcpp-Socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krozark%2Fcpp-Socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krozark%2Fcpp-Socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krozark%2Fcpp-Socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Krozark","download_url":"https://codeload.github.com/Krozark/cpp-Socket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224707897,"owners_count":17356433,"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":["cpp11","socket"],"created_at":"2024-08-03T02:01:48.030Z","updated_at":"2024-11-14T23:31:29.699Z","avatar_url":"https://github.com/Krozark.png","language":"C++","readme":"cpp-Socket\n==========\n\nCurrent build status : \n[![Build Status](https://travis-ci.org/Krozark/cpp-Socket.png?branch=master)](https://travis-ci.org/Krozark/cpp-Socket)\n\nTesting\n=======\n\nUbuntu 12.04+ x86/64\nWindows xp x86\n\n\nVersion : 0.2\n\nSome class to help to construct client/server with soket and serilized datas.\n\nIt also make some methode to make binary RPC. The binary is translate using the serializer before the send.\n\nthe data are send like this :\n|size|function id|param...|\nand the responce is like that :\n|size|response|\n\nNote:\n    It's important to know witch type are the parameters and the order.\n    It's the same for the result of the call.\n    Some function are build to don't make mistake :\n\n* Client::call(R (\\*fun)(SocketSerialized\u0026,Args... ),Args ...)\n* Server::exec(R (\\*fun)(SocketSerialized\u0026,Args ...),Args...)\n\nTest on Ubuntu 12+ x64, but based on multiplatforme code.\nUsed std::thread and std::mutex.\n\nImportant\n=========\n\nYou have to define your function dispatch. See the doc for more detail.\n\n```C++\n\nint dispatch(int id,ntw::SocketSerialized\u0026 request) //this function have to be made for a server, unless it will crash on first request. Not use by clients.\n{\n    //your code\n    return 0;\n};\n\nint main(int argc,char* argv[])\n{\n    ntw::Socketinit(dispatch); //init for windows and the server callback\n    //code\n    //ntw::Socket::close(); //clean the context\n    return 0;\n}\n\n\n```\n\n\nClass\n-----\n\nAll class are in ntw namespace.\n\n* ntw::Config\n    * define some values use for init server, client and SelectManager.\n        * max_connexion;\n        * port_server;\n        * port_client;\n        * default_timeout;\n\n* ntw::Serializer\n    * allow you to add datas to the buffer that are convert in Big Endian for the network\n    * allow you to add custom operators \\\u003c\\\u003c and \\\u003e\\\u003e  for easily use vour own class/stuct to convert.\n\n* ntw::Socket\n    * use C socket, and put them in a class to use them more easily\n\n* ntw::SocketSerialized\n    * Extand Socket and Serializer.\n    * Simply add that you want in this soket (using \\\u003c\\\u003c operator) send it, and get data (with \\\u003e\\\u003e operator)\n    * RPC call are made using this Socket class.\n\n* ntw::SelectManager\n    * Manage some Soket (just add some in it) and execute callback whene critera are satisfy (read,write, except)\n    * Run in a different thread for performence\n\n* ntw::BalancingSelector\n    * A groupe of SelectManager that do the same. It's use to split the number of socket to manage in defferent thread without having to do it.\n\n* ntw::FuncWrapper\n    * This class define some (static) base functions for the communication\n    * This class use a dispatch function tha you have to build\n    * exec is a shortcut tha unpack param of the function in firs param, containing in the request, and call it.\n\n```C++\n\nnamespace ntw\n{\n    void dispatch(int id,SocketSerialized\u0026 request)\n    {\n        switch(id)\n        {\n            case ntw::FuncWrapper::srv::FUNCTONS_ID::UNKNOW :\n            {\n                std::cerr\u003c\u003c\"[ERROR] dispatch, FUNCTONS_ID UNKNOW\"\u003c\u003cstd::endl;\n            }break;\n            case 1 :\n            {\n                exec(getVersion,request);\n            }break;\n            case  2 :\n            {\n                exec(testParamInt,request);\n            }break;\n            default:\n                std::cerr\u003c\u003c\"[ERROR] FuncWrapper::dispatch, FUNCTONS_ID not find: \"\u003c\u003cid\u003c\u003cstd::endl;\n        }\n    }\n}\n\n```\n\n* ntw::srv::Server\n    * this is the server implementation\n    * Just construct and start it , and that'is it.\n\n* ntw::cli::Client\n    * this is the client implemantation\n    * construct and connect it, and then, you can use the client.call((*pf)'SocketSerialized\u0026,...)...) to make a rpc call. pf is a fonction defined in FuncWrapper (client.call is a synchronous call).\n    * at the end, don't forget to call client.stop(), and client.wait() to stop the network thread.\n\n\nYou can build the lib with cmake.\n\n\n\n","funding_links":[],"categories":["Networking"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKrozark%2Fcpp-Socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKrozark%2Fcpp-Socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKrozark%2Fcpp-Socket/lists"}