>>>>> "t" == terry  <ter...@arcor.de> writes:

  t> 于 2011-3-16 8:31, Daniel Calvo 写道:
  >> while (<$fh>) {
  >> print;
  >> }


  t> For the first look, you shouldn't be using <> for receiving data from
  t> the socket. For more details, please loot at this article and its
  t> comments:

  t> http://www.perlfect.com/articles/select.shtml

that barely expands on the code the OP posted. and one tiny comment on
dealing with unbuffered reads. and that comment's code is missing all
the logic to deal with socket closing detection and more.

the best source for this is the book network programming in perl. it is
slightly old but still valuable in its coverage of buffering issues.

another solution for the OP, have your clients close their sockets or
use the shutdown call to close the write portion. if you are just
slurping in all of stdin, then the client needs to do no more than write
all of its data to the socket and exit or do one of the previous things
first.

also perldoc perlipc is a useful tutorial.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to