示例#1
0
 public function getPort()
 {
     $name = $this->socket->getSockName();
     return (int) substr(strrchr($name, ':'), 1);
 }
示例#2
0
 /**
  * @depends testServerNonBlocking
  */
 public function testServerNonBlockingAcceptClient(Socket $server)
 {
     // create local client connected to the given server
     $client = $this->factory->createClient($server->getSockName());
     // client connected, so we can not accept() this socket
     $peer = $server->accept();
     // peer should be writable right away
     $this->assertTrue($peer->selectWrite(0.1));
     $peer->write('test');
     // expect to receive the message in one chunk
     $this->assertEquals('test', $client->read(100));
     // disconnect local client
     $client->close();
     // disconnection should be detected withing 1s max
     $this->assertTrue($peer->selectRead(1.0));
     $peer->close();
 }
示例#3
0
 /**
  *
  * @param Socket $socket
  * @depends testCreateListenRandom
  * @expectedException Exception
  */
 public function testCreateListenInUseFails(Socket $socket)
 {
     $address = $socket->getSockName();
     $port = substr($address, strrpos($address, ':') + 1);
     $this->factory->createListen($port);
 }