{"id":20434615,"url":"https://github.com/arstgit/librdp","last_synced_at":"2026-04-21T04:02:34.013Z","repository":{"id":40440246,"uuid":"283902930","full_name":"arstgit/librdp","owner":"arstgit","description":"Reliable datagram protocol. C implementation.","archived":false,"fork":false,"pushed_at":"2023-03-23T04:27:42.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-05T06:32:36.459Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arstgit.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":"2020-07-31T00:14:37.000Z","updated_at":"2024-03-10T01:11:22.000Z","dependencies_parsed_at":"2025-01-15T18:21:27.149Z","dependency_job_id":"3f502421-d25e-4607-bbcb-8854686b3fa0","html_url":"https://github.com/arstgit/librdp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arstgit/librdp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arstgit%2Flibrdp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arstgit%2Flibrdp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arstgit%2Flibrdp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arstgit%2Flibrdp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arstgit","download_url":"https://codeload.github.com/arstgit/librdp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arstgit%2Flibrdp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32076295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-15T08:28:01.937Z","updated_at":"2026-04-21T04:02:33.997Z","avatar_url":"https://github.com/arstgit.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# librtp\n\nReliable datagram protocol based on UDP. More aggressive packet sending strategy.\n\n\n## Prerequisites\nEnvironment: \n  - Linux.\n\n## Compile \u0026 Install\n\n```\n  $ make\n  $ make install\n```\n\n## Usage\n\n```c\n// Note: RDP don't have automatic connection destroy mechanism. Once user get a connection handle, from the invocation of rdpNetConnect() or rdpReadPoll() with RDP_ACCEPT event,  it's always user's job to invoke rdpConnClose() to destroy that connection.\n\n// rdpSocketCreate() opens one fd internally.\nrdpSocket *ctx = rdpSocketCreate(1, \"127.0.0.1\", \"8888\");\n\n// Establish a connection.\nrdpConn *conn = rdpNetConnect(ctx, \"www.example.com\", \"8889\");\n\n// Arbitrary user data pointer can be attached to rdpConn.\n// User can retrive the user data whenever needed. Usually after getting a RDP_DATA/RDP_ACCEPT/RDP_CONNECTED/RDP_CONN_ERROR.\nvoid * userData = NULL;\nrdpConnSetUserData(conn, userData);\nassert(rdpConnGetUserData(c) == userData);\n\nint efd = epoll_create1(0);\n\n// This is the actual communicating fd rdpSocketCreate() using.\nint fd = rdpSocketGetProp(ctx, RDP_PROP_FD);\n\nstruct epoll_event ev, epollEvents[10];\nev.events = EPOLLIN | EPOLLET | EPOLLOUT;\nev.data.fd = fd;\nepoll_ctl(efd, EPOLL_CTL_ADD, fd1, \u0026ev);\n\nfor (;;) {\n  // rdpSocketIntervalAction() is needed to do some internal actions in time.\n  // Returns a timeout in milliseconds, indicating the time interval to next invoke. Usually passing it to epoll_wait is enough.\n  int timeout = rdpSocketIntervalAction(ctx);\n\n  n = epoll_wait(efd, epollEvents, 10, timeout);\n\n  for (i = 0; i \u003c n; i++) {\n    ev = epollEvents[i];\n\n    if ((ev.events \u0026 EPOLLERR) || (ev.events \u0026 EPOLLHUP)) {\n      goto exit;\n    }\n\n    if (ev.events \u0026 EPOLLIN) {\n      unsigned char buf[1024];\n      size_t len = 1024;\n      rdpConn *newConn;\n      int events;\n\n      for (;;) {\n        // rdpReadPoll() gives us information about connection establishment, data arrival, EOF etc.\n        // User should invoke it over and over again until getting a RDP_ERROR or RDP_AGAIN, that's the only safe point jumping out the loop.\n        ssize_t readCount = rdpReadPoll(ctx, buf, len, \u0026newConn, \u0026events);\n        if (events \u0026 RDP_ERROR) {\n          // Unexpected error, invalid arguments and internal fault can be the cause.\n          // User should check the arguments passing to rdpReadPoll().\n          goto exit;\n        }\n\n        if (events \u0026 RDP_AGAIN) {\n          // RDP has drained the underground fd.\n          // It's time to break the loop safely.\n          break;\n        }\n\n        if (events \u0026 RDP_CONN_ERROR) {\n          // Connection have errors, usually because of receiving a RESET packet.\n          // rdpConnClose() should be invoked here.\n\n          userData = rdpConnGetUserData(conn);\n          // Do some sweeping if needed.\n\n          if (rdpConnClose(conn) == -1) {\n            // Error occured.\n          }\n          \n          continue;\n        }\n\n        if (events \u0026 RDP_POLLOUT) {\n          // Indicate RDP have enough buffer space stroing output data now.\n          // It's time to write remaining data to sent if there is.\n          for (;;) {\n            int n = rdpWrite(newConn, \"echo something back\", 19);\n            if (n == -1 \u0026\u0026 errno == EAGAIN) {\n              printf(\n                  \"rdpWrite EAGAIN, try again when got an RDP_POLLOUT again\");\n            }\n            break;\n          }\n        }\n\n        if (events \u0026 RDP_ACCEPT) {\n          // New connection incoming.\n\n          struct sockaddr_storage addr;\n          socklen_t len;\n          // Fetch the address of the other end.\n          rdpConnGetAddr(newConn, (struct sockaddr *)\u0026addr, \u0026len);\n\n          // Do something.\n\n          // rdpConnClose() should be invoked here or somewhere else explicitly.\n        }\n\n        if (events \u0026 RDP_CONNECTED) {\n          // New connection established.\n\n          int n = rdpWrite(newConn, \"hello.\", 6);\n          if (n == -1 \u0026\u0026 errno == EAGAIN) {\n            printf(\"rdpWrite EAGAIN, try again when got an RDP_POLLOUT\");\n          }\n        }\n\n        if (events \u0026 RDP_DATA) {\n          // Data or EOF arrived.\n\n          if (readCount \u003e 0) {\n            // Data arrived.\n            printf(\"buf: %s, buf len: %d\", buf, readCount);\n\n            int n = rdpWrite(newConn, \"hello.\", 6);\n            if (n == -1 \u0026\u0026 errno == EAGAIN) {\n              printf(\"rdpWrite EAGAIN, try again when got an RDP_POLLOUT\");\n            }\n          }\n\n          if (readCount == 0) {\n            // Received an EOF from the other end.\n            printf(\"EOF\");\n\n            rdpConnClose(newConn);\n          }\n        }\n\n        if (events \u0026 RDP_CONTINUE) {\n          // Invoke rdpReadPoll() again immediately.\n          continue;\n        }\n      }\n    }\n  }\n}\n\nexit: \n  rdpSocketDestroy(ctx);\n```\n\n\n## Test\n```\n  $ make clean \u0026\u0026 make test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farstgit%2Flibrdp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farstgit%2Flibrdp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farstgit%2Flibrdp/lists"}