use strict; use IO::Socket; my $listen = new IO::Socket::INET ( LocalHost => $ENV{COMPUTERNAME}, LocalPort => q(7070), Proto => q(tcp), Listen => 1, Reuse => 1, ); my @input; while (1) { my $sock = $listen->accept(); while (<$sock>) { unshift(@input,$_); } close($sock); if ($input[0] eq q(END_TRANSFER)) { shift @input; @input = reverse @input; last; } } print qq($_\n) foreach @input;