ipentinmaki has asked for the wisdom of the Perl Monks concerning the following question:
#!/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 sta +rt"); 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 serve +rs socket # but when loop around again +the data is still there as server # has not written anything ne +w print STDERR "data was $data\n"; sleep 10; } close SOCK;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read Socket on Server
by Illuminatus (Curate) on Sep 29, 2008 at 22:07 UTC | |
by ipentinmaki (Initiate) on Sep 29, 2008 at 22:19 UTC | |
by ikegami (Patriarch) on Sep 29, 2008 at 22:41 UTC | |
by ipentinmaki (Initiate) on Sep 30, 2008 at 01:53 UTC | |
by ikegami (Patriarch) on Sep 30, 2008 at 02:24 UTC | |
|
Re: Read Socket on Server
by kubrat (Scribe) on Sep 30, 2008 at 22:22 UTC |