Jump to content

unable to read from socket [107]


Sillywhipper

Recommended Posts

Hi All, I have recently upgraded the mysql database on one of our webservers which seems to be working but I now get the following error from apache:

 

[sat Jun 18 02:19:13 2011] [error] [client 10.3.0.14] PHP Warning:  socket_read(): unable to read from socket [107]: Transport endpoint is not connected in /var/www/application/lib/Socket.class.php on line 47, referer: https://application.site.com/main.php

 

The code in Socket.class.php is as follows:

 

<?php
class Socket
{
        private $sock;

        public function __construct()
        {
                $this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
                socket_set_nonblock($this->sock);
        }
        public function __destruct()
        {
                socket_close($this->sock);
                $this->log("Connection closed on $this->sock.");
        }

        public function connect($ip, $port, $timeout=10)
        {
                $this->log("Connecting to $ip:$port...");

                $timeout = time()+$timeout;

                while (!@socket_connect($this->sock, $ip, $port))
                {
                        if (socket_last_error() == 111)
                        {
                                $this->log("Connection refused!");
                                return false;
                        }
                        else if (time() >= $timeout)
                        {
                                $this->log("Connection timed out!");
                                return false;
                        }

                        // 10ms
                        usleep(10000);
                }

                $this->log("Connected.");

                return true;
        }

        public function read($buffer = 1024)

        {
echo $buffer;
                $read = socket_read($this->sock, $buffer);

                if ($read)
                        $this->log("Reading:\n$read\n");

                return $read;
        }
        public function write($data)
        {
                $this->log("Writting:\n$data\n");
                return socket_write($this->sock, $data);
        }

        private function log($msg)
        {
                $msg = str_replace("\r\n", "\\r\\n\r\n", $msg);
                //echo "$msg\n";
                //echo str_pad(nl2br(htmlentities($msg)), 4094),"\n\n";
        }
}
?>

 

This application was working before I upgraded mysql which I think is unrelated because its working within the application and I don't recall changing anything else?

 

Any help would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/239659-unable-to-read-from-socket-107/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.