Sockets Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
agravayne
Forum Newbie
Posts: 8
Joined: Thu Dec 04, 2008 4:55 am

Sockets Help

Post 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
Post Reply