Sillywhipper Posted June 17, 2011 Share Posted June 17, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/239659-unable-to-read-from-socket-107/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.