Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

wepoll

> 编程语言
Open source

wepoll: fast epoll for windows⁧

1.1K stars0 likes0 views
WebsiteGitHub

About

wepoll: fast epoll for windows⁧

wepoll - epoll for windows

This library implements the epoll API for Windows applications. It is fast and scalable, and it closely resembles the API and behavior of Linux' epoll.

Rationale

Unlike Linux, OS X, and many other operating systems, Windows doesn't have a good API for receiving socket state notifications. It only supports the select and WSAPoll APIs, but they don't scale and suffer from other issues.

Using I/O completion ports isn't always practical when software is designed to be cross-platform. Wepoll offers an alternative that is much closer to a drop-in replacement for software that was designed to run on Linux.

Features

  • Can poll 100000s of sockets efficiently.
  • Fully thread-safe.
  • Multiple threads can poll the same epoll port.
  • Sockets can be added to multiple epoll sets.
  • All epoll events (EPOLLIN, EPOLLOUT, EPOLLPRI, EPOLLRDHUP) are supported.
  • Level-triggered and one-shot (EPOLLONESTHOT) modes are supported
  • Trivial to embed: you need only two files.

Limitations

  • Only works with sockets.
  • Edge-triggered (EPOLLET) mode isn't supported.

How to use

The library is distributed as a single source file (wepoll.c) and a single header file (wepoll.h).

Compile the .c file as part of your project, and include the header wherever needed.

Compatibility

  • Requires Windows Vista or higher.
  • Can be compiled with recent versions of MSVC, Clang, and GCC.

API

General remarks

  • The epoll port is a HANDLE, not a file descriptor.
  • All functions set both errno and GetLastError() on failure.
  • For more extensive documentation, see the epoll(7) man page, and the per-function man pages that are linked below.

epoll_create/epoll_create1

c
HANDLE epoll_create(int size);
HANDLE epoll_create1(int flags);
  • Create a new epoll instance (port).
  • size is ignored but most be greater than zero.
  • flags must be zero as there are no supported flags.
  • Returns NULL on failure.
  • Linux man page

epoll_close

c
int epoll_close(HANDLE ephnd);
  • Close an epoll port.
  • Do not attempt to close the epoll port with close(), CloseHandle() or closesocket().

epoll_ctl

c
int epoll_ctl(HANDLE ephnd,
              int op,
              SOCKET sock,
              struct epoll_event* event);
  • Control which socket events are monitored by an epoll port.

  • ephnd must be a HANDLE created by epoll_create() or epoll_create1().

  • op must be one of EPOLL_CTL_ADD, EPOLL_CTL_MOD, EPOLL_CTL_DEL.

  • sock must be a valid socket created by socket(), WSASocket(), or accept().

  • event should be a pointer to a struct epoll_event.

    If op is EPOLL_CTL_DEL then the event parameter is ignored, and it may be NULL.

  • Returns 0 on success, -1 on failure.

  • It is recommended to always explicitly remove a socket from its epoll set using EPOLL_CTL_DEL before closing it.

    As on Linux, closed sockets are automatically removed from the epoll set, but wepoll may not be able to detect that a socket was closed until the next call to epoll_wait().

  • Linux man page

epoll_wait

c
int epoll_wait(HANDLE ephnd,
               struct epoll_event* events,
               int maxevents,
               int timeout);
  • Receive socket events from an epoll port.
  • events should point to a caller-allocated array of epoll_event structs, which will receive the reported events.
  • maxevents is the maximum number of events that will be written to the events array, and must be greater than zero.
  • timeout specifies whether to block when no events are immediately available.
    • 1 | | EPOLLHUP | socket hang-up1 | |EPOLLRDNORM| same asEPOLLIN | |EPOLLRDBAND| same asEPOLLPRI | |EPOLLWRNORM| same asEPOLLOUT | |EPOLLWRBAND| same asEPOLLOUT | |EPOLLMSG` | never reported |
Flag Description
EPOLLONESHOT report event(s) only once
EPOLLET not supported by wepoll
EPOLLEXCLUSIVE not supported by wepoll
EPOLLWAKEUP not supported by wepoll

1: the EPOLLERR and EPOLLHUP events may always be reported by epoll_wait(), regardless of the event mask that was passed to epoll_ctl().

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言