Example #1
0
 /**
  * Метод создает новый сокет через socket_create.
  *
  * @return mixed
  * @throws Ext_Io_Net_Socket_Exception
  */
 protected function _createSocket()
 {
     if (is_null($this->_socket)) {
         $socket = socket_create($this->_family->getValue(), $this->_communicationType->getValue(), $this->_connectionString->getProtocolCode());
         if ($socket === false) {
             throw new Ext_Io_Net_Socket_Exception($this->getLastError(), $this->getLastErrorCode());
         }
         $this->_socket = $socket;
         if (is_resource($this->_socket)) {
             socket_set_option($this->_socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $this->_timeout, 'usec' => 0));
         }
     }
     return $this->_socket;
 }
Example #2
0
 /**
  * @test
  */
 public function fromString()
 {
     $connectionString = Ext_Io_ConnectionString::fromString('tcp://*****:*****@127.0.0.1:80');
     $this->assertEquals('tcp', $connectionString->protocol);
     $this->assertEquals('user', $connectionString->user);
     $this->assertEquals('password', $connectionString->password);
     $this->assertEquals('127.0.0.1', $connectionString->host);
     $this->assertEquals('80', $connectionString->port);
 }