...; use IO::Handle; STDOUT->autoflush(1); $socket->autoflush(1); ...;