drainToEAGAIN

private fnptrdiff_t drainToEAGAIN(int fd) @trusted nothrow @nogc

Drain a socket file descriptor to EAGAIN by reading and discarding.

Required helper for edge-triggered (EPOLLET) mode: user callbacks that read from a registered socket must continue reading until the syscall returns EAGAIN/EWOULDBLOCK, otherwise the kernel will not signal new readiness for data already buffered. Use this function to enforce the drain contract for protocols like HTTP/1.1 keep-alive where the client may send multiple requests in quick succession.

Parameters

fdNon-blocking socket file descriptor.

Returns

Number of bytes drained (discarded), or -1 on error.