note 52429 added to function.socket-set-option

From: Date: Sun, 01 May 2005 00:19:57 +0000
Subject: note 52429 added to function.socket-set-option
Groups: php.notes 
Request: Send a blank email to php-notes+get-88801@lists.php.net to get a copy of this message
To expand a bit more on what "tim at e2-media dot co dot nz" started. SO_SNDTIMEO is one of the many constants you can use with socket_set_option. See http://ca.php.net/manual/en/ref.sockets.php for the available Predefind Constants and visit http://man.he.net/man2/setsockopt for the meaning of the ones relevant. Tim's example might seem at first a bit non-intuitive since he is using the SO_SNDTIMEO constant. Which means, if the socket has to send out data, it must do it within the limit specified - in his case 10 seconds. Usually you won't set a timeout for sending out data. Nevertheless, the example is valid, and there are situations where you need to do so. A more intuitive use of socket_set_option would be to set a time out for a blocking socket (a socket that waits for data to be receive when read from). You would do this like so: socket_set_option($socket,SOL_SOCKET, SO_RCVTIMEO, array("sec"=>0, "usec"=>100)); Notice that sec= 0 and usec= 100; Depending on how long you want your program to wait to recieve data, you might want to change these values. Regards, drenintell ---- Manual Page -- http://www.php.net/manual/en/function.socket-set-option.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52429 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52429&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52429&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52429&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52429&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52429&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52429&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88801) next »