The OpenD Programming Language

ListeningConnectionManager

To use this thing:

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

The 4th parameter is optional.

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.

More...
class ListeningConnectionManager {
Semaphore semaphore;
Socket[256] queue;
shared(ubyte) nextIndexFront;
ubyte nextIndexBack;
shared(int) queueLength;
bool tcp;
void delegate() cleanup;
Socket[] listeners;
void delegate(Socket) handler;
immutable
bool useFork;
int numberOfThreads;
}

Detailed Description

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

Meta