Zidane has asked for the wisdom of the Perl Monks concerning the following question:
dear perl monks.
i am somewhat of a perl beginner, and over the last few months have grown to love the language. As an attempt to learn to use various modules, i have written the following perl script. It is the beginnings of a very basic irc client.
the whole script and the configuration file
########## #this is the bit that bugs out, afaik ########## #enter select group read wait loop my @ready_sockets; while (@ready_sockets = $select_group->can_read) { #for each socket..... foreach my $sock (@ready_sockets) { #pull data from the socket my $data = <$sock>; #if the data is null, socket is closed if (!($data)) { print "socket closed\n" if $debug; #pull it out of the select group $select_group->remove($sock); $sock->close; return; } print "socket replied: $data" if $debug; if (substr($data,0,4) eq "PING") { print "pong" . substr($data,4); print $sock "PONG" . substr($data,4); } } }
However, the script seems to have a problem that i cannot solve. when connecting to the irc server, the script correctly receives the first few lines, and then seems to ignore the data on the socket for a random amount of time. Oddly, it always pauses at the same point on each server, but it is a different point on each server. this leads the connection to time out.
it would appear that after reading the first few lines, the $select_group->can_read is not recognising data ready for reading on the socket. I do not know why.
so far i have tried the following to solve this problem:-
could anyone shed any light on this? i have been working on this all day and can see no reason at all why it should behave in this way. any help would be appreciated.
thankyou in advance.
|
|---|