Page 1 of 1

Sockets Help

Posted: Fri Oct 16, 2009 5:00 am
by agravayne
Hello all,

I have written a socket server and it all works fine but I am now trying to add some error handling.

This is the situation.

Client connects and send data.
Server acknowledges.
If there are commands cued for the client these are sent.
Client acknowledges command has been sent.
Connection is closed.

What I am trying to do is set a timeout on the client acknowledging the command sent. The server listens for the response using the code

Code: Select all

$response = socket_recv($tsock, $buf,1024,0);
$respdata.=$buf;
But if the client doesn't respond I believe that this sits there waiting. So how can I set a timeout on this socket_recv so that the code moves on after a set time of waiting?

Many thanks
Scott