{"id":16613185,"url":"https://github.com/c-cube/bencode_rpc","last_synced_at":"2025-06-29T18:03:20.018Z","repository":{"id":10912343,"uuid":"13210456","full_name":"c-cube/bencode_rpc","owner":"c-cube","description":"[toy] Remote Procedure Call with B-encode serialization and Lwt concurrency (probably not production ready).","archived":false,"fork":false,"pushed_at":"2017-01-04T11:38:20.000Z","size":161,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T23:15:28.623Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c-cube.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}},"created_at":"2013-09-30T08:50:49.000Z","updated_at":"2018-08-01T10:54:41.000Z","dependencies_parsed_at":"2022-09-02T10:51:06.652Z","dependency_job_id":null,"html_url":"https://github.com/c-cube/bencode_rpc","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/c-cube/bencode_rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fbencode_rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fbencode_rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fbencode_rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fbencode_rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-cube","download_url":"https://codeload.github.com/c-cube/bencode_rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-cube%2Fbencode_rpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262642964,"owners_count":23341816,"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-10-12T01:46:23.871Z","updated_at":"2025-06-29T18:03:19.956Z","avatar_url":"https://github.com/c-cube.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Bencode-RPC\n\nRemote Procedure Call in OCaml, with B-encode and Lwt.\n\nThis library allows to communicate through the network (TCP) using\na remote call abstraction. The data is serialized with\n[Bencode](http://en.wikipedia.org/wiki/Bencode).\n\nDocumentation is available [here](http://cedeela.fr/~simon/software/bencode_rpc/).\n\n### Install\n\nYou need OCaml\u003e=4.00, and the libraries `bencode`, `lwt` and `lwt.unix`.\n\n    $ make\n    $ make install\n\n### License\n\nReleased under the BSD2 license. See `LICENSE`.\n\n### Modules\n\nThe library provides the following modules, packed in the module `Bencode_rpc`:\n\n- `NetTcp`: management of TCP connections, and communication of `Bencode`\n  objects through sockets\n- `RPCServer`: RPC server implementation. Methods (functions from\n   Bencode messages to lwt-wrapped Bencode replies, basically) can be\n   registered under a name to the server.\n- `RPCClient`: connects to a server via TCP, and then allows to call\n   remote methods by their name (with a timeout) and get a future\n   response.\n- `Broadcast`: *untested* broadcasting algorithm for small networks.\n- `Lwt_queue`: a message queue for `Lwt`, for internal use\n- `Signal`: internal publish/subscribe implementation\n\n### Example\n\nSimple \"ping-pong\" client-server exchange (can be found in `tests/test1.ml`\nwith minor modifications).\n\n```ocaml\nopen Bencode_rpc;;\nmodule B = Bencode;;\n\n(* create a server that listens on some random TCP port *)\nlet server =\n  match RPCServer.create () with\n  | Some s -\u003e s\n  | None -\u003e failwith \"could not start server\"\n;;\n\nlet port = RPCServer.port server;;\n\n(* register a method \"ping\" on the server. That remote method\n   will reply \"pong\" whenever it receives \"ping\". *)\nRPCServer.register server \"ping\" (fun _addr_sender msg -\u003e\n  match msg with\n  | B.String \"ping\" -\u003e RPCServer.reply (B.String \"pong\")\n  | _ -\u003e RPCServer.error \"error: expected \\\"ping\\\"\");;\n\nlet (\u003e\u003e=) = Lwt.(\u003e\u003e=);;\n\nLwt_main.run (\n  (* create a client that tries to connect on the local port of the server *)\n  RPCClient.local port\n  \u003e\u003e= function\n  | None -\u003e failwith \"could not connect to server port\"\n  | Some client -\u003e\n\n  (* call the remote method \"ping\" with the message \"ping\" (in Bencode)\n     and a timeout of 2 seconds. *)\n  RPCClient.call ~timeout:2. client \"ping\" (B.String \"ping\")\n  \u003e\u003e= function\n    | RPCClient.Reply (B.String \"pong\") -\u003e\n      Lwt_io.printl \"success!\"\n    | RPCClient.Reply _ -\u003e failwith \"client: bad response\"\n    | RPCClient.Error msg -\u003e failwith (\"client: got error \" ^ msg)\n    | RPCClient.NoReply -\u003e failwith \"client: timeout\"\n);;\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-cube%2Fbencode_rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-cube%2Fbencode_rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-cube%2Fbencode_rpc/lists"}