note 35381 added to function.usleep
| From: | grail dot ink at unix dot net | Date: | Fri, 29 Aug 2003 07:06:19 +0000 |
| Subject: | note 35381 added to function.usleep | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55277@lists.php.net to get a copy of this message | ||
We have developed an alternative to usleep that should work on any platform and it doesn't eat
up any CPU cycles. It's been tested on Windows 2000 w/ Apache. Other platforms should work
fine.
function microdelay($delay) {
$UNUSED_PORT=31238; //make sure this port isn't being used on your server
@fsockopen("tcp://localhost",$UNUSED_PORT,$errno,$errstr,$delay);
}
It times out after a specified time in seconds. It uses a double as argument so you can specify
decimal arguments.
microdelay(.5); //500ms
microdelay(.25); //250ms
microdelay(2.25); //2250ms
Our small contribution to this great language!
http://www.xencoders.com
----
Manual Page -- http://www.php.net/manual/en/function.usleep.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35381
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35381&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35381&report=yes