Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^4: Problem with IO::Select

by timos (Beadle)
on Mar 01, 2007 at 00:46 UTC ( #602628=note: print w/replies, xml ) Need Help??

in reply to Re^3: Problem with IO::Select
in thread Problem with IO::Select

Ah, ok. So I changed it to
my $rx_txt = "something"; while (length($rx_txt) > 0) { $conn->recv($rx_txt, 1024); $buff.=$rx_txt; }
But the problem stays the same.

Replies are listed 'Best First'.
Re^5: Problem with IO::Select
by Thelonius (Priest) on Mar 01, 2007 at 01:07 UTC
    You probably meant to write:
    while ($rh->recv($rx_txt, 1024) > 0) { $buff .= $rx_txt; }
    But that's not good code when using 'select'. That's only okay if you're only handling one connection at a time. If you're only handling one connection at a time, don't use select.

    Also, I hope you know that adding a file handle for "~/.somefile" only makes sense if it's a fifo (named pipe).

    There are actually a lot of problems with your code. You should probably look at something somebody else has written. I recommend The Perl Cookbook, although there are a lot of free examples scattered about the internet.

Re^5: Problem with IO::Select (won't block)
by tye (Sage) on Mar 01, 2007 at 01:26 UTC

    "can_read" really means "trying to read won't block", which means that end-of-file will cause can_read to keep returning "true" forever. That might be your problem.

    You need to detect end-of-file and then (probably) close the socket and stop asking if you can read from it.

    - tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://602628]
[Discipulus]: or a spanish one: ' qui mucho se despide no quiere despedirse'
shmem slides into the envelope
[shmem]: Discipulus *quien*
[Discipulus]: quien ..
[Discipulus]: me too, i need a Dumas time, see you
[shmem]: que descanses bien, aprendiz
shmem wuff & wech
[shmem]: erm. wrong link. wrong link!
[shmem]: que descanses bien, aprendiz
[Discipulus]: bravo!

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-04-29 22:59 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (534 votes). Check out past polls.