469,963 Members | 1,203 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

Read/Write IO on socket file descriptor?

Hi all,

I'm trying to perform read and write I/O on a socket file descriptor
received for another process via a Unix Domain Socket. In trying to
understand all this I came up with a small test script that is not
working for me:
use strict ;
use IO::Socket::INET ;

my $socket = new IO::Socket::INET(
PeerAddr => 'www.perl.com',
PeerPort => 80,
Proto => 'tcp',
) ;

my $rfd = fileno($socket) ;
my $rfh = new IO::Handle->fdopen($rfd, "r") ;
my $wfd = fileno($socket) ;
my $wfh = new IO::Handle->fdopen($wfd, "w") ;

print "$rfd $rfh $wfd $wfh\n" ;
print $wfh "GET / HTTP/1.0\n\n" ;
print "Sent GET...\n" ;
my $line = <$rfh> ;
print $line ;
Should this work? It seems as though printing to $wfh
does nothing, and then the <$rfh> is hanging.

If this is not the way to go about this, what else can I do
to perform read AND write I/O on a socket file descriptor?

I'm using Perl 5.6.1 on Linux RH 7.1

Thanks,

Patrick LeBoutillier
Jul 19 '05 #1
1 9930

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by zhushenli | last post: by
5 posts views Thread by Martin Svensson | last post: by
8 posts views Thread by Patrik Malmström | last post: by
2 posts views Thread by Paul M | last post: by
2 posts views Thread by David Lozzi | last post: by
10 posts views Thread by lorenzogordon | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.