PHP: stream_socket_server ()

I have a home PHP TCP chat server, but it has no way to detect remote disconnects.

I would appreciate it if someone knew how easy it is to take stream_socket_server () and spit out everything related to it.

Then you can run such a loop in psuedocode:

$main_socket=stream_socket_server("tcp://",....) //Do Something.... say, wait for a connection (with stream_socket_accept())? for (each CONNECTION in $main_socket) { //Do something with or to that connection } //Loop back... if you need to say, wait for another connection 

Alternatively , I can check if the variable created using $ stream_socket_accept () is connected.

This project is destroyed until I find out. I would be grateful to everyone who could help me with this!

+4
source share
1 answer

The correct way to find out if the remote host has disconnected is to check for false socket_read() , as far as I know.

Take a look at this question; PHP - remote host disconnect detection

+1
source

All Articles