note 59281 added to function.socket-listen

From: Date: Thu, 01 Dec 2005 15:17:10 +0000
Subject: note 59281 added to function.socket-listen
Groups: php.notes 
Request: Send a blank email to php-notes+get-99422@lists.php.net to get a copy of this message
// How to set up a UDP polling service using a system trigger // avoiding intensive pooling loop // set up a socket $sux = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); if (!$sux) exit('create error'); // designate a port on the socket to recieve data if (!socket_bind($sux, $local_ip, 2210)) exit('bind error'); $suxref[] =& $sux; // create a reference to the socket as an array $ip = ''; $port = 0; do { // let the system take care of polling for UDP data socket_select($suxref, $write = NULL, $except = NULL, 5); // sec. timout // get the UDPdata with the sender's IP/port $z = @socket_recvfrom($sux, $buf, 9999, 0, $ip, $port); // return some data to the sender IP/port if (strlen($buf) > 0) { echo "\r\nRemote sent: " . $buf; socket_sendto($sux, "I hear you", 9999, 0x4, $ip, $port); } } while(true); ---- Manual Page -- http://www.php.net/manual/en/function.socket-listen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59281 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59281&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59281&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59281&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59281&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59281&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59281&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59281&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59281&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99422) next »