Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Socket programming

by Jonathan (Curate)
on Oct 06, 2000 at 14:52 UTC ( #35558=note: print w/ replies, xml ) Need Help??


in reply to Socket programming

I would change the client side

#!/usr/local/bin/perl use IO::Socket; # create a tcp connection to the specified host and port $server = IO::Socket::INET->new( Proto => "tcp", PeerAddr => 'localhost', PeerPort => '6969' ), or die "can't connect to server: $!"; print "[Client $0 connected to server]\n"; print $server "READY\n"; while (defined ($this_line = <$server>)) { print STDOUT $this_line; if ($this_line =~ /STOP/i) { last; } } close $server;


connects ok. On the server side I like to run with autoflush on. e.g. adding use FileHandle; and then $server->autoflush(1); after you have opened the socket. I believe select $server;$|=1 will do the same thing. <BR

"We are all prompted by the same motives, all deceived by the same fallacies, all animated by hope, obstructed by danger, entangled by desire, and seduced by pleasure." - Samuel Johnson


Comment on Re: Socket programming
Select or Download Code
Replies are listed 'Best First'.
RE: Re: Socket programming
by Zarathustra (Beadle) on Oct 07, 2000 at 05:17 UTC

    Just a little heads-up, from IO::Socket's docs:

    As of VERSION 1.18 all IO::Socket objects have autoflush turned on
    by default. This was not the case with earlier releases.


    So no need for toggling the buffering.

    Cheers!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://35558]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2015-07-28 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls