########### use strict; use IO::Socket; my $Unix; if ($^O =~ m/unix|linux|sunos|solaris|freebsd|aix/i) { $Unix = 1 } else { $Unix = 0 } my $sock = new IO::Socket::INET ( LocalPort => '8181', Proto => 'tcp', Listen => SOMAXCONN, ReuseAddr => $Unix, ); die "Could not create socket: $!\n" unless $sock; $| = 1; my $client = $sock->accept(); print "Message1\n"; print $client "Message1\n"; # You can release client here. if not - later it will be blocked. #close($client); # Something that wastes time + separate process creator my $cmd; if ($Unix) { $cmd = 'pause 10'; $cmd .= ' &'; } else { $cmd = 'pause'; $cmd = 'cmd.exe /c start cmd.exe /c ' . $cmd; } # This will block both Unix and Win clients if the server is on Win system($cmd); close($client); $sock->shutdown(2); close($sock);