Jump to content

socket_read() error


The Little Guy

Recommended Posts

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.