I'm having some trouble with my perl script which uses IO::Select and
IO::Socket to multiplex incoming connections as described here

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

Now, I am able to connect to the script using telnet, but when I try
to connect to it with my php script which will be used to connect to
the script in production, I get

send: Cannot determine peer address at
/usr/local/www/root/trunk/html/bin/fluxd/fluxd.pl line 603

Since I'm able to connect to it with telnet, I'm leaning towards a
problem with the way php is connecting to it, but I just wanted to
make sure that everything looks good here.

use strict;
use warnings;

my $Select = new IO::Select();

$SERVER = IO::Socket::UNIX->new(
               Type    => SOCK_STREAM,
               Local   => $PATH_SOCKET,
               Listen  => 16,
               Reuse   => 1,
               );
$Select->add($SERVER);


#------------------------------------------------------------------------------#
# Sub: checkConnections                                                        #
# Arguments: null                                                              #
# Returns: null                                                                #
#------------------------------------------------------------------------------#
sub checkConnections {
       # Get the readable handles. timeout is 0, only process stuff that can be
       # read NOW.
       my $return = "";
       my @ready = $Select->can_read(0);
       foreach my $socket (@ready) {
               if ($socket == $SERVER) {
                       my $new = $socket->accept();
                       $Select->add($new);
               } else {
                       my $buf = "";
                       my $char = getc($socket);
                       while ((defined($char)) && ($char ne "\n")) {
                               $buf .= $char;
                               $char = getc($socket);
                       }
                       if ($buf) {
                               $return = processRequest($buf);
                               $socket->send($return);
                       } else {
                               $Select->remove($socket);
                               close($socket);
                       }
               }
       }
}

--
I'm nerdy in the extreme and whiter than sour cream

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to