Question about socket_select

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

It appears to me that something is strange with the socket_select function.
>From what I understand the value of the fourth parameter, tv_sec,
should block the execution of the script for that number of seconds.
I tried this code :
<?php

error_reporting(E_ERROR);

$serverSocket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

$result = socket_bind($serverSocket, "127.0.0.1", "20668");

$start = time();

while(true)
{
    $reads = array($serverSocket);
    $writes = null;
    $except = null;
    $changes = socket_select($reads, $writes, $except, 5);
    $now = time();
    echo $now - $start;
    echo "\n";
}

and when I run it with php -q server3.php the ouput shows something
like 0 0 0 0 0 1 1 1 1 1 2 2 2 2 etc so the script doesn't pause on
socket_select until it returns.

Cam somebody explain me what's happening ?

Thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux