#!/usr/bin/perl -w use IO::Socket; use strict; #sock is my connection where I report what is going on my $sock = IO::Socket::INET->new(PeerAddr => 'hostname.org', PeerPort => '1234', Proto => 'tcp' ); my $return_value = long_running_function(); print $sock "$return_value\n"; close $sock;