This modules aims to provide a simple TCP server. It will listen on a port you specify, accept incoming connections and remove them again when they're dead. It provides three simple callbacks at the moment, but I plan to add a few more.

A hash with function references assigned to callback names. Currently, four callbacks are supported. "add" is called when a new connection was accepted. If it returns a false value, the connection is kicked again right away. "remove" is called when a connection got lost. "data" is called when there's pending data on a connection. If the callback function returns false, the connection is removed afterwards. "tick" is called at the beginning of every cycle, that means at least every timeout seconds, or earlier if the select returned early because of incoming traffic. All callbacks except "tick" are called with the peer socket and the daemon object itself as argument (IO::Socket::INET). Tick get's undef instead of the peer socket.

This can be called from a callback to stop the server. This simply sets a variable, so after the next cycle the server breaks out of the main loop. At the moment, if you run the server again after stopping it, it will completely start over again, so all connections etc. are lost. This might probably change in future.

This takes a client connection (IO::Socket::INET) as argument, closes the connection and removes it from the internal connection list. You can use this in your callbacks to explicitly kill connections. If you return a false value from the "data" or "add" callback, this is called automatically.

This module was hacked together within a few minutes, so there are probably lots of bugs. On the other hand, it's very few code, so there can't be that much bugs in it. Just try it out and tell me if it's broken.