#!/usr/local/bin/perl use strict; use Socket; use IO::Handle; my $prot = getprotobyname('tcp'); my $host = inet_aton("localhost"); socket(SOCK, AF_INET, SOCK_STREAM, $prot) or die("socket failed to start"); my $dest_addr = sockaddr_in(5003, $host); connect(SOCK, $dest_addr) or die("Connect failed"); my $data; while (1) { print STDERR "do a read\n"; sysread(SOCK, $data, 1024); # reads the data on the servers socket # but when loop around again the data is still there as server # has not written anything new print STDERR "data was $data\n"; sleep 10; } close SOCK;