maxl90 has asked for the wisdom of the Perl Monks concerning the following question:
And here is the client side....use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'qnxa227', LocalPort => '7070', Proto => 'tcp', Listen => 1, Reuse => 1 ); die "Could not creat socket: $!\n" unless $sock; $sock->autoflush(1); print "The server is up and ready\n"; my $new_sock =$sock ->accept() || die " error $new_sock"; #### This just goes around an infinite loop gathering info while(1){ sleep(2); if( $ARGV[0] eq "l"){ & short; print "\n"; & long; } elsif( $ARGV[0] eq "lp"){ & short; print "\n"; & pfilter; } else { @x = (& short( $new_sock)); print($new_sock $x[0]),"\n"; print($new_sock $x[1]),"\n"; print($new_sock $x[2]),"\n"; } } close($sock);
Thanks A Lot!use IO::Socket::INET; $file = "info.txt"; #open(stdout,">>$file"); ### one way of trying to output to a file $sock = IO::Socket::INET->new( PeerAddr => '10.8.74.227', PeerPort => '7070', Proto => 'tcp'); print "client running\n"; my $byte; while (sysread($sock, $byte, 1) == 1) { print $byte; } close($sock);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sockets and Output
by Coruscate (Sexton) on Jan 15, 2003 at 23:23 UTC | |
|
Re: Sockets and Output
by Thelonius (Priest) on Jan 15, 2003 at 22:53 UTC | |
|
Re: Sockets and Output
by pg (Canon) on Jan 16, 2003 at 04:42 UTC |