Reputation: 929
I created a socket server with 10 possible clients by using socket_accept(socket). It is possible to connect up to 10 times now.
The problem appears after the first client submitted a message to the server which is caught by
$data = @socket_read($clients[$i]['socket'], 1024, PHP_NORMAL_READ);
Then the script tries to listen for clients and messages again by socket_accept and socket_read, but all socket_accept-requests fail with the error string "Invalid argument".
var_dump indicates that the parameter is a resource(14) of type (Socket), though.
Already connected clients can continue using the "server" script as nothing happened and remain connected. Only new clients are unable to connect and the port seems to close (no telnet and netcat requests are possible - connection refused)
Any ideas would be helpful. Thanks!
Upvotes: 0
Views: 235
Reputation: 929
Discovered that I assumed to disconnect all sockets when the destructor of the socket handler class was called - which terminated all connections once the child process closed.
Removing the socket_shutdown() and socket_close() from the destructor solved the problem.
Upvotes: 1