public function open()
    {
        $this->_open = false;
        $this->_handler->beforeOpen();
        $this->_socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if ($this->_socket === false) {
            throw new TcpException(
            	'Error opening socket: ' . socket_strerror(socket_last_error())
            );
        }
        if ($this->_reuse) {
            socket_set_option ($this->_socket, SOL_SOCKET, SO_REUSEADDR, 1);
        }
        if (!@socket_bind($this->_socket, $this->_address, $this->_port)) {
            $error = socket_strerror(socket_last_error($this->_socket));
            socket_close($this->_socket);
            $this->_socket = false;
            throw new TcpException('Error binding socket: ' . $error);
        }
        socket_set_nonblock($this->_socket);
        $this->_handler->beforeListen();
        if (!socket_listen($this->_socket, $this->_backlog)) {
            $error = socket_strerror(socket_last_error($this->_socket));
            socket_close($this->_socket);
            $this->_socket = false;
            throw new TcpException('Error listening socket: ' . $error);
        }
        $this->_open = true;
    }
public function open()
    {
        $this->_open = false;
        $this->_handler->beforeOpen();
        $this->_socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if ($this->_socket === false) {
            throw new TcpException(
            	'Error opening socket: ' . socket_strerror(socket_last_error())
            );
        }
        if ($this->_reuse) {
            socket_set_option ($this->_socket, SOL_SOCKET, SO_REUSEADDR, 1);
        }
        if (!@socket_bind($this->_socket, $this->_address, $this->_port)) {
            $error = socket_strerror(socket_last_error($this->_socket));
            socket_close($this->_socket);
            $this->_socket = false;
            throw new TcpException('Error binding socket: ' . $error);
        }
        socket_set_nonblock($this->_socket);
        $this->_handler->beforeListen();
        if (!socket_listen($this->_socket, $this->_backlog)) {
            $error = socket_strerror(socket_last_error($this->_socket));
            socket_close($this->_socket);
            $this->_socket = false;
            throw new TcpException('Error listening socket: ' . $error);
        }
        $this->_open = true;
    }
public function open ( ) { $ this -> _open = false ; $ this -> _handler -> beforeOpen ( ) ; $ this -> _socket = socket_create ( AF_INET , SOCK_STREAM , SOL_TCP ) ; if ( $ this -> _socket === false ) { throw new TcpException ( 'Error opening socket: ' . socket_strerror ( socket_last_error ( ) ) ) ; } if ( $ this -> _reuse ) { socket_set_option ( $ this -> _socket , SOL_SOCKET , SO_REUSEADDR , 1 ) ; } if ( ! @ socket_bind ( $ this -> _socket , $ this -> _address , $ this -> _port ) ) { $ error = socket_strerror ( socket_last_error ( $ this -> _socket ) ) ; socket_close ( $ this -> _socket ) ; $ this -> _socket = false ; throw new TcpException ( 'Error binding socket: ' . $ error ) ; } socket_set_nonblock ( $ this -> _socket ) ; $ this -> _handler -> beforeListen ( ) ; if ( ! socket_listen ( $ this -> _socket , $ this -> _backlog ) ) { $ error = socket_strerror ( socket_last_error ( $ this -> _socket ) ) ; socket_close ( $ this -> _socket ) ; $ this -> _socket = false ; throw new TcpException ( 'Error listening socket: ' . $ error ) ; } $ this -> _open = true ; }
Call this to bind the socket and start listening for connections.
Will also set the socket non blocking.

@throws TcpException
@return void
Call this to bind the socket and start listening for connections . Will also set the socket non blocking .