/**
  * @param string $address (optional)
  * @param integer $port (optional)
  * @param integer $maxClients (optional)
  *
  * @throws \InvalidArgumentException If address is not valid
  * @throws \InvalidArgumentException If port is not in valid range
  */
 public function __construct(ContainerInterface $container, $address = '*', $port = 1962, $maxClients = 100)
 {
     parent::__construct();
     $this->container = $container;
     $this->isIPv6 = false;
     $this->address = $address;
     $this->port = $port;
     $this->maxClients = $maxClients;
     // convert wildcard address
     if ('*' == $this->address) {
         $this->address = '0.0.0.0';
     }
     // validate [IPv4/6] address
     if (false === filter_var($this->address, FILTER_VALIDATE_IP)) {
         throw new \InvalidArgumentException(sprintf('The address "%s" is not a valid IP address', $this->address));
     }
     // cover IPv6 address in braces
     if (true === filter_var($this->address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
         $this->isIPv6 = true;
     }
     // validate port number
     if (0 > $this->port || 65535 < $this->port) {
         throw new \InvalidArgumentException('The port number must range from 0 to 65535');
     }
 }
 /**
  * @param Bundle\ServerBundle\Socket\ServerSocket $server
  * @param integer $timeout (optional)
  * @param integer $keepAliveTimeout (optional)
  */
 public function __construct(ServerSocket $server, $timeout = 90, $keepAliveTimeout = 15)
 {
     $this->server = $server;
     $this->request = null;
     $this->response = null;
     $this->timeout = $timeout;
     $this->keepAliveTimeout = $keepAliveTimeout;
     $this->keepAlive = false;
     $this->accepted = time();
     $this->lastAction = $this->accepted;
     parent::__construct($this->server->accept());
     // set timeout
     $this->setTimeout($this->timeout);
 }