Logo Search packages:      
Sourcecode: egroupware-egw-pear version File versions  Download package

Net_Socket::select ( state,
tv_sec,
tv_usec = 0 
)

Runs the equivalent of the select() system call on the socket with a timeout specified by tv_sec and tv_usec.

Parameters:
integer $state Which of read/write/error to check for.
integer $tv_sec Number of seconds for timeout.
integer $tv_usec Number of microseconds for timeout.
public
Returns:
False if select fails, integer describing which of read/write/error are ready, or PEAR_Error if not connected.

Definition at line 521 of file Socket.php.

    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        $read = null;
        $write = null;
        $except = null;
        if ($state & NET_SOCKET_READ) {
            $read[] = $this->fp;
        }
        if ($state & NET_SOCKET_WRITE) {
            $write[] = $this->fp;
        }
        if ($state & NET_SOCKET_ERROR) {
            $except[] = $this->fp;
        }
        if (false === ($sr = stream_select($read, $write, $except, $tv_sec, $tv_usec))) {
            return false;
        }

        $result = 0;
        if (count($read)) {
            $result |= NET_SOCKET_READ;
        }
        if (count($write)) {
            $result |= NET_SOCKET_WRITE;
        }
        if (count($except)) {
            $result |= NET_SOCKET_ERROR;
        }
        return $result;
    }


Generated by  Doxygen 1.6.0   Back to index