I'm working on getting a script to work (see below). It is a perl
daemon associated with a bittorent client that I am helping develop.
The daemon uses unix domain sockets to commincate with the php pages.
However, anytime a message is sent via php, the script dies with

send: Cannot determine peer address at
/usr/local/www/root/tf-b4rt/trunk/html/bin/fluxd/fluxd.pl line 1256

I did some reasearch and found a similar problem with OpenBSD's perl
http://www.nntp.perl.org/group/perl.perl5.porters/2007/02/msg121151.html

and tried to apply that fix to my own Socket.pm's. I modified these files
[EMAIL PROTECTED] p5-IO]$ locate Socket.pm
/usr/home/andy/.cpan/build/IO-1.2301/IO/Socket.pm
/usr/home/andy/.cpan/build/IO-1.2301/blib/lib/IO/Socket.pm
/usr/local/lib/perl5/5.8.8/mach/IO/Socket.pm
/usr/local/lib/perl5/5.8.8/mach/Socket.pm

and re-started my process, but no effect. the bug report above
suggests that this was a problem for OpenBSD due to differences in
struct sockaddr_un. Could that be a problem here as well?

the php code which communicates with the socket is below

-----------------begin php--------------
   /**
    * send command
    *
    * @param $command
    * @param $read does this command return something ?
    * @return string with retval or null if error
    */
   function instance_sendCommand($command, $read = 0) {
       if ($this->state == FLUXD_STATE_RUNNING) {
               // create socket
               $socket = -1;
           $socket = @socket_create(AF_UNIX, SOCK_STREAM, 0);
           if ($socket < 0) {
               array_push($this->messages , "socket_create() failed:
reason: "[EMAIL PROTECTED]($socket));
               $this->state = FLUXD_STATE_ERROR;
               return null;
           }
           //timeout after n seconds
               @socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO,
array('sec' => $this->_socketTimeout, 'usec' => 0));
           // connect
           $result = -1;
           $result = @socket_connect($socket, $this->_pathSocket);
           if ($result < 0) {
               array_push($this->messages , "socket_connect() failed:
reason: "[EMAIL PROTECTED]($result));
               $this->state = FLUXD_STATE_ERROR;
               return null;
           }
           // write command
           @socket_write($socket, $command."\n");
           // read retval
           $return = "";
           if ($read != 0) {
                               do {
                                       // read data
                                       $data = @socket_read($socket,
4096, PHP_BINARY_READ);
                                       $return .= $data;
                               } while (isset($data) && ($data != ""));
           }
           // close socket
           @socket_close($socket);
           // return
           return $return;
       } else { // fluxd not running
               return null;
       }
   }
-----------------end php---------------------------

and the perl daemon's socket code is below

------------------begin perl----------------------
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);
                       }
                       $return = processRequest($buf);
                       $socket->send($return);
                       $select->remove($socket);
                       close($socket);
               }
       }
}
-------------------------end perl----------------------

I can provide the full text of the appropriate files on request or you
can view them at
http://svn.berlios.de/wsvn/tf-b4rt/trunk/?rev=0&sc=0

perl-5.8.8
apache-2.2.4_2
php5-5.2.1_3
php5-gd-5.2.1_3
php5-pcre-5.2.1_5
php5-pgsql-5.2.1_3
php5-posix-5.2.1_3
php5-session-5.2.1_3
php5-simplexml-5.2.1_3
php5-sockets-5.2.1_3
php5-spl-5.2.1_3
php5-sqlite-5.2.1_3

FreeBSD zeus.agreenftp.no-ip.com 6.2-STABLE FreeBSD 6.2-STABLE #0: Sat
Mar 31 23:12:40 EDT 2007
[EMAIL PROTECTED]:/usr/obj/usr/src/sys/ZEUS  i386

--
--
I'm nerdy in the extreme and whiter than sour cream
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to