{"id":23236800,"url":"https://github.com/pratikpc/asio-ntp","last_synced_at":"2025-04-05T21:17:39.143Z","repository":{"id":125287859,"uuid":"363361556","full_name":"pratikpc/Asio-NTP","owner":"pratikpc","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-01T20:31:12.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-02-12T00:38:49.361Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pratikpc.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":"2021-05-01T08:35:56.000Z","updated_at":"2022-12-17T22:23:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"df1d79c9-867a-4a4e-ac14-002202fb4184","html_url":"https://github.com/pratikpc/Asio-NTP","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/pratikpc%2FAsio-NTP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pratikpc%2FAsio-NTP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pratikpc%2FAsio-NTP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pratikpc%2FAsio-NTP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pratikpc","download_url":"https://codeload.github.com/pratikpc/Asio-NTP/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399897,"owners_count":20932881,"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-19T04:12:45.279Z","updated_at":"2025-04-05T21:17:39.120Z","avatar_url":"https://github.com/pratikpc.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Asio Network Time Protocol\n\n\n## Sample Usage\n\n```cpp\n // Change URL to point to your favourite NTP server\n auto connection = co_await pc::ntp::Connection::make_connection(\"in.pool.ntp.org\");\n // Get Time as Unix Epoch\n std::uint32_t time_s = co_await connection.TimeFromUnixEpoch();\n std::cout \u003c\u003c \"Time is \" \u003c\u003c time_s;\n```\n\nIt is that easy.\n\nWe are utilising [Asio Standalone](https://think-async.com/Asio/) and using the latest and greatest Coroutines to simplify the code.  \nWithout coroutines of any form, be it Boost.Coroutine or others, the code would be full of callbacks and would be almost unreadable,  \nat least for mere mortals such as yours truly.\n\n## Customization\n\n### Send a packet yourself\n```cpp     \n ntp::Packet sendPacket;\n // Set li = 0, vn = 3, and mode = 3\n sendPacket.li_vn_mode = 0b00100011;\n\n co_await connection.Packet(sendPacket);\n```\nWhere connection is a connection object\n\n### Receive a packet yourself\n```cpp\n  ntp::Packet const packet = connection.co_await Packet();\n```\n\n### Resolve sockets myself instead of using Helper Function\n```cpp\n  udp::resolver resolver{executor};\n  endpoint_t    receiver_endpoint =\n      *(co_await resolver.async_resolve(protocol, host, \"ntp\", use_awaitable));\n```\nYour friendly neighbourhood Asio code to resolve UDP sockets\n\n```cpp\n  ntp::Connection connection{executor,\n                             receiver_endpoint.protocol(),\n                             std::forward\u003cendpoint_t\u003e(receiver_endpoint)};\n```\nAnd your friendly neighhbourhood constructor\n\n## Contact me\nFor further details, you can contact me [via LinkedIn](https://www.linkedin.com/in/pratik-chowdhury-889bb2183/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikpc%2Fasio-ntp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpratikpc%2Fasio-ntp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikpc%2Fasio-ntp/lists"}