To use this thing:

void handler(Socket s) { do something... } auto manager = new ListeningConnectionManager("", 80, &handler); manager.listen();

I suggest you use BufferedInputRange(connection) to handle the input. As a packet comes in, you will get control. You can just continue; though to fetch more.

class ListeningConnectionManager {
Semaphore semaphore;
Socket[256] queue;
shared(ubyte) nextIndexFront;
ubyte nextIndexBack;
shared(int) queueLength;
bool tcp;
void delegate() cleanup;
Socket listener;
void function(Socket) handler;
bool running;

Detailed Description

FIXME: should I offer an event based async thing like netman did too? Yeah, probably.