Hello gentlemen. Thanks for the replies. Terry, before mailing the list I already had stumbled upon that page. I thought it was less clearer than the perl-doc page, I couldn't grasp it at first like with perl-doc.
Uri, thanks a lot for the pointers. Yes, what my clients are doing is dumping all of stdin to a given socket. My problem was handling multiple clients on the server side. I will check that book though, seems promissing. And perlipc too. Thanks again. It seems I had this problem due to my poor understanding of when to use threads. I managed to put together the following code, which I don't know if its any good, but its working. use IO::Select; use IO::Socket; use threads; $lsn = new IO::Socket::INET(Listen => 1, LocalPort => 9000); $sel = new IO::Select ( $lsn ); while (@ready = $sel->can_read) { foreach $fh (@ready) { if ($fh == $lsn) { $new = $lsn->accept; $sel->add($new); } else { my $t = threads -> new (\&subprint, $fh); push (@threads, $t); } } } foreach (@threads){ $_->join; } sub subprint { my $fhh = shift; while (<$fhh>){ print; } $sel->remove($fhh); $fhh->close; } 2011/3/15 Uri Guttman <u...@stemsystems.com> > >>>>> "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/ > > >