Create a blocking and timeout client

This is a discussion on Create a blocking and timeout client within the PHP Language forums, part of the PHP Programming Forums category; The client program I tried to create will send some message to another program on a different server and block ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-22-2004
Mike
 
Posts: n/a
Default Create a blocking and timeout client

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
Reply With Quote
  #2 (permalink)  
Old 09-23-2004
Mike
 
Posts: n/a
Default Re: Create a blocking and timeout client

Anyone has any idea?

michma@gmail.com (Mike) wrote in message news:<8e9b7c06.0409211906.84ad3c4@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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:47 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0