SPUG: IO::Socket Question
daryn at marinated.org
Thu Aug 10 12:42:53 CDT 2000
I think you (and everyone else) are on the right track. However, it still
doesn't work :)
If I open up the socket to a web server and request a page (so I'm
getting a decent amount of data back) it works fine.
however, with the server I'm connecting to, where all it replies with is
one work, it hangs on the line referencing <$sock>
print $result = <$sock>;
print scalar <$sock>;
all with that same result.
Any other suggestions?
On Wed, 9 Aug 2000 ced at carios2.ca.boeing.com wrote:
> > $sock = IO::Socket::INET->new(
> > PeerAddr => "thehost",
> > PeerPort => theportnumber,
> > Proto => "tcp")
> > or die "Error connecting: $@\n";
> > $sock->autoflush(1);
> > print $sock "Hello\n";
> > print <$sock>;
> > close ($sock);
> > This sends the first "Hello" okay, but hangs waiting for the response. I'm
> > assuming it's a buffering problem, but autoflush(1) didn't seem to help.
> > Any suggestions for making this work?
> The print <$sock> establishes a list context so the socket
> read may be blocking trying to read multiple lines.
> Not sure if this is relevant in your case but would be
> a problem if this were the SMTP for instance.
> A fix might be:
> print scalar <$sock>;
> Charles DeRykus
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For full traffic, use spug-list for LIST ; otherwise use spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list