{"id":13735815,"url":"https://github.com/ringabout/wepoll","last_synced_at":"2025-03-18T19:38:25.470Z","repository":{"id":43604876,"uuid":"284136255","full_name":"ringabout/wepoll","owner":"ringabout","description":"Windows epoll wrapper for Nim.","archived":false,"fork":false,"pushed_at":"2024-11-26T08:52:21.000Z","size":57,"stargazers_count":22,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-02T00:04:17.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ringabout.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-31T21:53:30.000Z","updated_at":"2024-12-12T14:19:25.000Z","dependencies_parsed_at":"2025-01-02T00:04:19.443Z","dependency_job_id":"e86a7e3b-37ea-4dcc-8810-6fb6e6acdf3c","html_url":"https://github.com/ringabout/wepoll","commit_stats":{"total_commits":23,"total_committers":3,"mean_commits":7.666666666666667,"dds":"0.21739130434782605","last_synced_commit":"b6d836b2e3eb7a1744dd86c60d825b893339d2d7"},"previous_names":["xflywind/wepoll"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ringabout%2Fwepoll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ringabout%2Fwepoll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ringabout%2Fwepoll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ringabout%2Fwepoll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ringabout","download_url":"https://codeload.github.com/ringabout/wepoll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244290454,"owners_count":20429363,"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-08-03T03:01:11.572Z","updated_at":"2025-03-18T19:38:25.444Z","avatar_url":"https://github.com/ringabout.png","language":"Nim","funding_links":[],"categories":["Operating System"],"sub_categories":["IO"],"readme":"# wepoll\nWindows epoll wrapper based on [wepoll](https://github.com/piscisaureus/wepoll)\n\n## Installation\n\n```\nnimble install wepoll\n```\n\n\n## API\n\nDocs from https://github.com/piscisaureus/wepoll\n\n### General remarks\n\n* The epoll port is a `EpollHandle`, not a file descriptor.\n* All functions set both `errno` and `GetLastError()` on failure.\n* For more extensive documentation, see the [epoll(7) man page][man epoll],\n  and the per-function man pages that are linked below.\n\n### epoll_create/epoll_create1\n\n```nim\nproc epoll_create*(size: cint): EpollHandle\nproc epoll_create1*(flags: cint): EpollHandle\n```\n\n* Create a new epoll instance (port).\n* `size` is ignored but most be greater than zero.\n* `flags` must be zero as there are no supported flags.\n* Returns `NULL` on failure.\n* [Linux man page][man epoll_create]\n\n### epoll_close\n\n```nim\nproc epoll_close*(ephnd: EpollHandle): cint\n```\n\n* Close an epoll port.\n* Do not attempt to close the epoll port with `close()`,\n  `CloseHandle()` or `closesocket()`.\n\n### epoll_ctl\n\n```nim\nproc epoll_ctl*(ephnd: EpollHandle, op: cint, \n                sock: EpollSocket, event: ptr EpollEvent): cint {.wepoll.}\n```\n\n* Control which socket events are monitored by an epoll port.\n* `ephnd` must be a EpollHandle created by\n  [`epoll_create()`](#epoll_createepoll_create1) or\n  [`epoll_create1()`](#epoll_createepoll_create1).\n* `op` must be one of `EPOLL_CTL_ADD`, `EPOLL_CTL_MOD`, `EPOLL_CTL_DEL`.\n* `sock` must be a valid socket created by [`socket()`][msdn socket],\n  [`WSASocket()`][msdn wsasocket], or [`accept()`][msdn accept].\n* `event` should be a pointer to a [`EpollEvent`](#object-EpollEvent).\u003cbr\u003e\n  If `op` is `EPOLL_CTL_DEL` then the `event` parameter is ignored, and it\n  may be `NULL`.\n* Returns 0 on success, -1 on failure.\n* It is recommended to always explicitly remove a socket from its epoll\n  set using `EPOLL_CTL_DEL` *before* closing it.\u003cbr\u003e\n  As on Linux, closed sockets are automatically removed from the epoll set, but\n  wepoll may not be able to detect that a socket was closed until the next call\n  to [`epoll_wait()`](#epoll_wait).\n* [Linux man page][man epoll_ctl]\n\n### epoll_wait\n\n```nim\nproc epoll_wait*(ephnd: EpollHandle, events: ptr EpollEvent, \n                 maxevents: cint, timeout: cint): cint {.wepoll.}\n```\n\n* Receive socket events from an epoll port.\n* `events` should point to a caller-allocated array of\n  [`EpollEvent`](#object-EpollEvent) object, which will receive the\n  reported events.\n* `maxevents` is the maximum number of events that will be written to the\n  `events` array, and must be greater than zero.\n* `timeout` specifies whether to block when no events are immediately available.\n  - `\u003c0` block indefinitely\n  - `0`  report any events that are already waiting, but don't block\n  - `≥1` block for at most N milliseconds\n* Return value:\n  - `-1` an error occurred\n  - `0`  timed out without any events to report\n  - `≥1` the number of events stored in the `events` buffer\n* [Linux man page][man epoll_wait]\n\n### object EpollEvent\n\n```nim\ntype\n  EpollHandle* = pointer\n\n  EpollSocket* = culonglong\n```\n\n```nim\ntype\n  EpollData* {.bycopy, union.} = object\n    p*: pointer\n    fd*: cint\n    u32*: uint32\n    u64*: uint64\n    sock*: EpollSocket         ##  Windows specific\n    hnd*: EpollHandle          ##  Windows specific\n```\n\n```nim\ntype\n  EpollEvent* {.bycopy.} = object\n    events*: uint32          ##  Epoll events and flags\n    data*: EpollData         ##  User data variable\n```\n\n* The `events` field is a bit mask containing the events being\n  monitored/reported, and optional flags.\u003cbr\u003e\n  Flags are accepted by [`epoll_ctl()`](#epoll_ctl), but they are not reported\n  back by [`epoll_wait()`](#epoll_wait).\n* The `data` field can be used to associate application-specific information\n  with a socket; its value will be returned unmodified by\n  [`epoll_wait()`](#epoll_wait).\n* [Linux man page][man epoll_ctl]\n\n| Event         | Description                                                          |\n|---------------|----------------------------------------------------------------------|\n| `EPOLLIN`     | incoming data available, or incoming connection ready to be accepted |\n| `EPOLLOUT`    | ready to send data, or outgoing connection successfully established  |\n| `EPOLLRDHUP`  | remote peer initiated graceful socket shutdown                       |\n| `EPOLLPRI`    | out-of-band data available for reading                               |\n| `EPOLLERR`    | socket error\u003csup\u003e1\u003c/sup\u003e                                             |\n| `EPOLLHUP`    | socket hang-up\u003csup\u003e1\u003c/sup\u003e                                           |\n| `EPOLLRDNORM` | same as `EPOLLIN`                                                    |\n| `EPOLLRDBAND` | same as `EPOLLPRI`                                                   |\n| `EPOLLWRNORM` | same as `EPOLLOUT`                                                   |\n| `EPOLLWRBAND` | same as `EPOLLOUT`                                                   |\n| `EPOLLMSG`    | never reported                                                       |\n\n| Flag             | Description               |\n|------------------|---------------------------|\n| `EPOLLONESHOT`   | report event(s) only once |\n| `EPOLLET`        | not supported by wepoll   |\n| `EPOLLEXCLUSIVE` | not supported by wepoll   |\n| `EPOLLWAKEUP`    | not supported by wepoll   |\n\n\u003csup\u003e1\u003c/sup\u003e: the `EPOLLERR` and `EPOLLHUP` events may always be reported by\n[`epoll_wait()`](#epoll_wait), regardless of the event mask that was passed to\n[`epoll_ctl()`](#epoll_ctl).\n\n\n[man epoll]:        http://man7.org/linux/man-pages/man7/epoll.7.html\n[man epoll_create]: http://man7.org/linux/man-pages/man2/epoll_create.2.html\n[man epoll_ctl]:    http://man7.org/linux/man-pages/man2/epoll_ctl.2.html\n[man epoll_wait]:   http://man7.org/linux/man-pages/man2/epoll_wait.2.html\n[msdn accept]:      https://msdn.microsoft.com/en-us/library/windows/desktop/ms737526(v=vs.85).aspx\n[msdn socket]:      https://msdn.microsoft.com/en-us/library/windows/desktop/ms740506(v=vs.85).aspx\n[msdn wsasocket]:   https://msdn.microsoft.com/en-us/library/windows/desktop/ms742212(v=vs.85).aspx\n[select scale]:     https://daniel.haxx.se/docs/poll-vs-select.html\n[wsapoll broken]:   https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/\n[wepoll.c]:         https://github.com/piscisaureus/wepoll/blob/dist/wepoll.c\n[wepoll.h]:         https://github.com/piscisaureus/wepoll/blob/dist/wepoll.h\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fringabout%2Fwepoll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fringabout%2Fwepoll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fringabout%2Fwepoll/lists"}