public function start()
    {
        if (false === ($this->socket = @socket_create(AF_INET, SOCK_STREAM, getprotobyname($this->config['protocol'])))) {
            throw new Exception(sprintf('socket_create(AF_INET, SOCK_STREAM, <%s>) failed: [%d] %s',
                $this->config['protocol'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_bind($this->socket, $this->config['ip'], $this->config['port'])) {
            throw new Exception(sprintf('socket_bind($socket, "%s", %d) failed: [%d] %s',
                $this->config['ip'], $this->config['port'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_getsockname($this->socket, $this->config['ip'], $this->config['port'])) {
            throw new Exception(sprintf('socket_getsockname($socket, "%s", %d) failed: [%d] %s',
                $this->config['ip'], $this->config['port'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_listen($this->socket)) {
            throw new Exception(sprintf('socket_listen($socket) failed: [%d] %s', $code = socket_last_error(), socket_strerror($code)));
        }

        $this->started = true;

        $this->log('Listening for connections on <pop>'.$this.'</pop>', Logger::INFO);
    }
public function start()
    {
        if (false === ($this->socket = @socket_create(AF_INET, SOCK_STREAM, getprotobyname($this->config['protocol'])))) {
            throw new Exception(sprintf('socket_create(AF_INET, SOCK_STREAM, <%s>) failed: [%d] %s',
                $this->config['protocol'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_bind($this->socket, $this->config['ip'], $this->config['port'])) {
            throw new Exception(sprintf('socket_bind($socket, "%s", %d) failed: [%d] %s',
                $this->config['ip'], $this->config['port'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_getsockname($this->socket, $this->config['ip'], $this->config['port'])) {
            throw new Exception(sprintf('socket_getsockname($socket, "%s", %d) failed: [%d] %s',
                $this->config['ip'], $this->config['port'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_listen($this->socket)) {
            throw new Exception(sprintf('socket_listen($socket) failed: [%d] %s', $code = socket_last_error(), socket_strerror($code)));
        }

        $this->started = true;

        $this->log('Listening for connections on <pop>'.$this.'</pop>', Logger::INFO);
    }
public function start ( ) { if ( false === ( $ this -> socket = @ socket_create ( AF_INET , SOCK_STREAM , getprotobyname ( $ this -> config [ 'protocol' ] ) ) ) ) { throw new Exception ( sprintf ( 'socket_create(AF_INET, SOCK_STREAM, <%s>) failed: [%d] %s' , $ this -> config [ 'protocol' ] , $ code = socket_last_error ( ) , socket_strerror ( $ code ) ) ) ; } if ( false === @ socket_bind ( $ this -> socket , $ this -> config [ 'ip' ] , $ this -> config [ 'port' ] ) ) { throw new Exception ( sprintf ( 'socket_bind($socket, "%s", %d) failed: [%d] %s' , $ this -> config [ 'ip' ] , $ this -> config [ 'port' ] , $ code = socket_last_error ( ) , socket_strerror ( $ code ) ) ) ; } if ( false === @ socket_getsockname ( $ this -> socket , $ this -> config [ 'ip' ] , $ this -> config [ 'port' ] ) ) { throw new Exception ( sprintf ( 'socket_getsockname($socket, "%s", %d) failed: [%d] %s' , $ this -> config [ 'ip' ] , $ this -> config [ 'port' ] , $ code = socket_last_error ( ) , socket_strerror ( $ code ) ) ) ; } if ( false === @ socket_listen ( $ this -> socket ) ) { throw new Exception ( sprintf ( 'socket_listen($socket) failed: [%d] %s' , $ code = socket_last_error ( ) , socket_strerror ( $ code ) ) ) ; } $ this -> started = true ; $ this -> log ( 'Listening for connections on <pop>' . $ this . '</pop>' , Logger :: INFO ) ; }
Starts the server
Starts the server