in reply to Background Run

This seems to work:

use warnings; use strict; use IO::Socket; my $socket = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => '8888', Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Could not create socket: $!\n" unless $socket; $|++; while (1) { my $incoming = $socket->accept(); while(<$incoming>) { print $_; } print "\nNext session.\n"; } close($socket);

Here is how I run it as a daemon in Unix:

$ nohup ./listen.pl >listen.log 2>listen.log &

After it is running, here I am testing it out:

$ telnet localhost 8888 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. You there? ^] telnet> quit Connection closed.

And here is the output showing up in my log:

$ cat listen.log You there? Next session.

And here is the process still running afterwards.

$ jobs [1]+ Running nohup ./listen.pl > listen.log 2> listen.log &