#! perl # this listens for new tcp connections and hands them over to the server core # wether this being an extension introduces or reduces stability problems # is unknown as of today. use Socket; use IO::Socket::INET; our $LISTEN = new IO::Socket::INET LocalPort => cf::settings->csport, Listen => 1, ReuseAddr => 1; if (!$LISTEN) { # extension yes, completely stupid, not yet warn "unable to establish listen sockect, exiting.\n"; exit (2); } Event->io (fd => $LISTEN, poll => 'r', data => cf::WF_AUTOCANCEL, cb => sub { my ($fh, $peername) = $LISTEN->accept or return; my $fd = fileno $fh; my $host = inet_ntoa +(sockaddr_in $peername)[1]; warn "new connection from $host\n"; cf::add_client_socket $fd, $host; });