By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,719 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,719 IT Pros & Developers. It's quick & easy.

Create a blocking and timeout client

P: n/a
The client program I tried to create will send some message to another
program on a different server and block wait for reply message. If
connection is timeout, close the socket.

I did something like

$socket = socket_create (AF_INET, SOCK_STREAM, 0);

if (!socket_set_block($socket)) { // $socket is now blocking
echo socket_strerror(socket_last_error());
}

$time_soc = array("sec"=>10, "usec"=>0);
if (!socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $time_soc))
{
die("error message is:
".socket_strerror(socket_last_error($socket))) ;
}

Is this the right way to do it? PHP fails at socket_set_option. Thanks
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Anyone has any idea?

mi****@gmail.com (Mike) wrote in message news:<8e*************************@posting.google.c om>...
The client program I tried to create will send some message to another
program on a different server and block wait for reply message. If
connection is timeout, close the socket.

I did something like

$socket = socket_create (AF_INET, SOCK_STREAM, 0);

if (!socket_set_block($socket)) { // $socket is now blocking
echo socket_strerror(socket_last_error());
}

$time_soc = array("sec"=>10, "usec"=>0);
if (!socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $time_soc))
{
die("error message is:
".socket_strerror(socket_last_error($socket))) ;
}

Is this the right way to do it? PHP fails at socket_set_option. Thanks

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.