Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Using select() on only one socket

by ambrus (Abbot)
on Sep 04, 2005 at 10:24 UTC ( #489038=note: print w/replies, xml ) Need Help??


in reply to Using select() on only one socket

Sorry for stating the obvious if you have done all of the below.

First, you should just try to change the loop to a simple

while (1){ $line = <$socket>; print $line; }
for testing.

If that prints the lines, then I don't know what the problem is.

If that doesn't print anything either, then the problem is probably not in the select loop. It could be that you don't receive complete lines, as others have suggested; or that you don't receive any data on the socket (maybe the other side is waiting for you to send something first); or that you are trying to read from a listening socket (as opposed to an accepted or a connected socket).

Also you have checked that the loop actually starts, the program doesn't hang somewhere before that, haven't you?

Replies are listed 'Best First'.
Re^2: Using select() on only one socket
by ivanatora (Sexton) on Sep 04, 2005 at 10:40 UTC
    I tried that, and it prints the incoming line. Also the select loops starts. I've change the following:
    print "bob\n"; my $sel = IO::Select->new(); $sel->add($sock); while (1){ print "!"; if ($b = $sel->can_read(0.5)){ $line = <$socket>; print $line; } else { print "."; } } #end of while 1
    I see 'bob' printed, so the program is running there. After that I see infinite '!'s, so the loop starts. But nothing more. No dots, no lines.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2021-01-27 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?