SPUG: IO::Socket Question

Daryn Nakhuda daryn at marinated.org
Wed Aug 9 20:15:35 CDT 2000


Hi, I'm trying to use IO::Socket to open a socket connection (duh) and
communicate w/ a server.  A typical session would look like:

ME: hello
SERVER: hello

the code looks like this:

$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? 

thanks.

Daryn


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     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/



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     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 mailing list