High-performance I/O multiplexing including epoll, IOCP, kqueue, and io_uring
Implements high-performance I/O multiplexing for game servers handling 100K+ concurrent connections. Triggers when you need epoll, io_uring, kqueue, or IOCP code for scalable network handling, event loops, or connection management patterns.
/plugin marketplace add pluginagentmarketplace/custom-plugin-server-side-game-dev/plugin install server-side-game-dev-plugin@pluginagentmarketplace-game-serverThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/io-benchmarks.yamlreferences/GUIDE.mdreferences/IO_MODELS.mdscripts/epoll_example.pyscripts/helper.pyImplement high-performance I/O handling for thousands of concurrent connections.
| Model | Platform | Connections | Latency |
|---|---|---|---|
| epoll | Linux | 100K+ | Low |
| kqueue | BSD/macOS | 100K+ | Low |
| IOCP | Windows | 100K+ | Low |
| io_uring | Linux 5.1+ | 1M+ | Lowest |
| select | All | ~1000 | Medium |
#include <sys/epoll.h>
int epollfd = epoll_create1(0);
// Add socket
struct epoll_event ev;
ev.events = EPOLLIN | EPOLLET; // Edge-triggered
ev.data.fd = client_socket;
epoll_ctl(epollfd, EPOLL_CTL_ADD, client_socket, &ev);
// Event loop
struct epoll_event events[MAX_EVENTS];
while (running) {
int nfds = epoll_wait(epollfd, events, MAX_EVENTS, timeout_ms);
for (int i = 0; i < nfds; i++) {
if (events[i].events & EPOLLIN) handleRead(events[i].data.fd);
if (events[i].events & EPOLLOUT) handleWrite(events[i].data.fd);
}
}
#include <liburing.h>
struct io_uring ring;
io_uring_queue_init(256, &ring, 0);
// Submit read
struct io_uring_sqe *sqe = io_uring_get_sqe(&ring);
io_uring_prep_recv(sqe, socket_fd, buffer, BUFFER_SIZE, 0);
io_uring_sqe_set_data(sqe, &connection);
io_uring_submit(&ring);
// Reap completions
struct io_uring_cqe *cqe;
io_uring_wait_cqe(&ring, &cqe);
Connection* conn = io_uring_cqe_get_data(cqe);
handleCompletion(conn, cqe->res);
io_uring_cqe_seen(&ring, cqe);
class GameServer {
int epollfd;
void run() {
while (running) {
pollEvents(16); // 16ms = 60 FPS budget
gameTick();
broadcastState();
}
}
void pollEvents(int timeout_ms) {
struct epoll_event events[1024];
int n = epoll_wait(epollfd, events, 1024, timeout_ms);
for (int i = 0; i < n; i++) {
handleEvent(events[i]);
}
}
};
| Error | Root Cause | Solution |
|---|---|---|
| EMFILE | Too many fds | Increase ulimit |
| Missed events | Level-triggered bug | Use edge-triggered |
| Starvation | Unbalanced load | Round-robin |
| High latency | Blocking call | Async everything |
# Check fd limits
ulimit -n
# Monitor fd usage
ls /proc/$(pgrep game-server)/fd | wc -l
# Check epoll stats
cat /proc/$(pgrep game-server)/fdinfo/3
TEST(EpollServer, HandlesMultipleConnections) {
EpollServer server(8080);
vector<TcpClient> clients(100);
for (auto& client : clients) {
client.connect("localhost", 8080);
}
EXPECT_EQ(server.connectionCount(), 100);
}
assets/ - I/O benchmarksreferences/ - Platform guidesThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.