The Little Guy Posted September 19, 2011 Share Posted September 19, 2011 I have a socket server that is running on a while loop, the server listens for something to write to the stream, when something does write to the stream the server prints out the following: Warning: socket_read(): unable to read from socket [107]: Transport endpoint is not connected It fails on this line: $read = socket_read($socket, $length); with the above error (found in method "hear") What does the error mean, and how can I fix it? any thoughts would be great! Server: require_once 'phpLive.php'; $live->listen(function(){ global $live; if(($heard = $live->hear())){ echo "I heard: $heard\n"; } }); Class: public function hear($socket_id = 0, $length = 1024){ if(!isset($this->sockets[$socket_id])) $socket_id = $this->socket_connect(); $socket = $this->sockets[$socket_id]; if(is_resource($socket)){ $this->allow($socket_id); $read = socket_read($socket, $length); if(is_string($read)){ $this->quick_string = $read; $this->function_name = __FUNCTION__; return $this; } } return false; } public function allow($socket_id = 0){ if(!isset($this->sockets[$socket_id])) $socket_id = $this->socket_connect(); $socket = $this->sockets[$socket_id]; socket_accept($socket); $this->function_name = __FUNCTION__; return true; } Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/247406-socket_read-error/ Share on other sites More sharing options...
The Little Guy Posted September 19, 2011 Author Share Posted September 19, 2011 Needed to save the new client to an array, and read from that client Quote Link to comment https://forums.phpfreaks.com/topic/247406-socket_read-error/#findComment-1270538 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.