☰

# std/epoll

Theme:

- Manual
- Standard library
- Index
- Compiler docs
- Fusion docs
- devel, stable

Search:
Source Edit

# Imports

posix

# Types

    EpollData {.importc: "epoll_data_t", header: "<sys/epoll.h>", pure, final, union.} = object
      fd* {.importc: "fd".}: cint
      u32* {.importc: "u32".}: uint32
      u64* {.importc: "u64".}: uint64

  Source Edit

    EpollEvent {.importc: "struct epoll_event", header: "<sys/epoll.h>", pure, final.} = object
      events*: uint32
      data*: EpollData

  Source Edit

# Consts

    EPOLL_CTL_ADD = 1

  Source Edit

    EPOLL_CTL_DEL = 2

  Source Edit

    EPOLL_CTL_MOD = 3

  Source Edit

    EPOLLERR = 0x00000008

  Source Edit

    EPOLLET = -2147483648

  Source Edit

    EPOLLEXCLUSIVE = 268435456

  Source Edit

    EPOLLHUP = 0x00000010

  Source Edit

    EPOLLIN = 0x00000001

  Source Edit

    EPOLLMSG = 0x00000400

  Source Edit

    EPOLLONESHOT = 1073741824

  Source Edit

    EPOLLOUT = 0x00000004

  Source Edit

    EPOLLPRI = 0x00000002

  Source Edit

    EPOLLRDBAND = 0x00000080

  Source Edit

    EPOLLRDHUP = 0x00002000

  Source Edit

    EPOLLRDNORM = 0x00000040

  Source Edit

    EPOLLWAKEUP = 536870912

  Source Edit

    EPOLLWRBAND = 0x00000200

  Source Edit

    EPOLLWRNORM = 0x00000100

  Source Edit

# Procs

    proc epoll_create(size: cint): cint {.importc: "epoll_create",
                                          header: "<sys/epoll.h>", ...raises: [],
                                          tags: [], forbids: [].}

  Creates an epoll instance. Returns an fd for the new instance.

  The "size" parameter is a hint specifying the number of file descriptors to be associated with the new instance. The fd returned by epoll_create() should be closed with close().

  Source Edit

    proc epoll_create1(flags: cint): cint {.importc: "epoll_create1",
                                            header: "<sys/epoll.h>", ...raises: [],
                                            tags: [], forbids: [].}

  Same as epoll_create but with an FLAGS parameter. The unused SIZE parameter has been dropped. Source Edit

    proc epoll_ctl(epfd: cint; op: cint; fd: cint | SocketHandle;
                   event: ptr EpollEvent): cint {.importc: "epoll_ctl",
        header: "<sys/epoll.h>", ...raises: [], tags: [], forbids: [].}

  Manipulate an epoll instance "epfd". Returns `0` in case of success, `-1` in case of error (the "errno" variable will contain the specific error code).

  The "op" parameter is one of the `EPOLL_CTL_*` constants defined above. The "fd" parameter is the target of the operation. The "event" parameter describes which events the caller is interested in and any associated user data.

  Source Edit

    proc epoll_wait(epfd: cint; events: ptr EpollEvent; maxevents: cint;
                    timeout: cint): cint {.importc: "epoll_wait",
                                           header: "<sys/epoll.h>", ...raises: [],
                                           tags: [], forbids: [].}

  Wait for events on an epoll instance "epfd". Returns the number of triggered events returned in "events" buffer. Or -1 in case of error with the "errno" variable set to the specific error code. The "events" parameter is a buffer that will contain triggered events. The "maxevents" is the maximum number of events to be returned ( usually size of "events" ). The "timeout" parameter specifies the maximum wait time in milliseconds (-1 == infinite).

  This function is a cancellation point and therefore not marked with __THROW.

  Source Edit