The problem I'm having is that VLC ends up with many connections in a CLOSE_WAIT state, and a positive RECV buffer (according to netstat). Because the RC interface is limited to a single simultaneous connection, the instance is, at this point, hung until restart... presumably waiting for a FIN from the client, which has already disconnected.
I'm using the rc "logout" command so that vlc should initiates the close, but CLOSE_WAIT shouldn't be reached in that case.
I'm not sure how I get into this state, so if anybody has any advice to offer, I'm all ears. Thanks.
Code: Select all
// connect
if(FALSE === ($this->Sock = @fsockopen($this->Host, $this->Port, $errno, $errStr, 3)))
throw(new Exception("Could not connect to host {$this->Host} at port {$this->Port} error: $errStr ($errNo)"));
// short timeout
stream_set_timeout($this->Sock, 3);
// send command
if(FALSE === fwrite($this->Sock, "$command\n"))
throw(new Exception("Write fail: $command"));
// sleep
sleep(0.25);
// read response (shoudl probably be done with a select, instead of a sleep and read)
$response = fgets($this->Sock);
// clean logougt
if(FALSE === fwrite($this->Sock, "logout\n"))
throw(new Exception("Write fail: logout"));
// close down
if(!@fclose($this->Sock))
throw(new Exception("Unclean close of sock"));