Skip to content

Instantly share code, notes, and snippets.

View arnetheduck's full-sized avatar

Jacek Sieka arnetheduck

View GitHub Profile
@arnetheduck
arnetheduck / accept.c
Created December 5, 2025 14:23
Single socket, multiple threads
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <pthread.h>
#include <netdb.h>
@arnetheduck
arnetheduck / queue.nim
Created January 12, 2026 14:15
chronos accept queue
import chronos, std/sequtils
type
TransportFut = Future[StreamTransport].Raising([CancelledError, TransportError])
Server = ref object
socket: StreamServer
acceptLoop: Future[void].Raising([])
acceptQueue: AsyncQueue[TransportFut]