473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 10104

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zhushenli | last post by:
Hello all, How to random read/write the file in fstream? BTW, how to access the file in block? Regards, Davy
5
by: Martin Svensson | last post by:
Hello! I need some help/recommendations on how to do the following. I have a program that writes an IP address two control numbers and a date to file, on one line. It's a basic text file and it...
8
by: Patrik Malmström | last post by:
How do I read, write a file binary? I want to open, say, file.exe read it in to the program, then write it out to file2.exe. Like file copy, anyone have a code sample?
2
by: Paul M | last post by:
Hy all In c# how can I read/write ini file? I need this for back compatibility. Is possible little example? For future, what is the best practice to replace ini file? app.config? xml files??...
0
by: Ahmed A. | last post by:
This will be very helpfull for many! Using RichTextBox Read/Write Unicode File http://www.microsoft.com/indonesia/msdn/wnf_RichTextBox.as p Private Function ReadFile(ByVal myfile As String)...
3
by: Trint Smith | last post by:
Is there anything like this that will allow a url address instread of a drive letter?: Dim fw As StreamWriter fw = New StreamWriter("D:\file.txt", True) fw.WriteLine(ex) fw.Close() The...
2
by: David Lozzi | last post by:
Howdy, Trying to open and read/write another aspx file from my aspx page. Basically I want to be able to update my aspx files from the website. Here's my code so far: Dim path As String =...
10
by: lorenzogordon | last post by:
Hi there, I'd greatly appreciate any insights into the following problem: I've got PHP running fine on IIS (OS: Server 2003, SP1; IIS: 6.0; PHP: 4.3.11). In PHP, the user uploads a file,...
9
mickey0
by: mickey0 | last post by:
Hi, I have one problem; I must read a html like this; <html> <body> Hello </body> </html> I read this in a string (correct?) and after I have to do some changes to it and write it on disk...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.