Exemple #1
0
 /**
  * Create a connection to the FastCGI application
  */
 protected function connect()
 {
     if ($this->sock) {
         return;
     }
     if ($this->port) {
         $this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
         $address = $this->host;
         $port = $this->port;
     } else {
         $this->sock = socket_create(AF_UNIX, SOCK_STREAM, 0);
         $address = $this->host;
         $port = 0;
     }
     if (!$this->sock) {
         throw CommunicationException::socketCreate();
     }
     if (false === socket_connect($this->sock, $address, $port)) {
         throw CommunicationException::socketConnect($this->sock, $this->host, $this->port);
     }
     if ($this->_readWriteTimeout && !$this->setMsTimeout($this->_readWriteTimeout)) {
         throw new CommunicationException('Unable to set timeout on socket');
     }
 }
Exemple #2
0
 /**
  * Create a connection to the FastCGI application
  */
 private function connect()
 {
     if (!$this->sock) {
         if ($this->socketPath !== null) {
             $this->sock = @socket_create(AF_UNIX, SOCK_STREAM, 0);
             $address = $this->socketPath;
             $port = 0;
         } else {
             $this->sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
             $address = $this->host;
             $port = $this->port;
         }
         if (!$this->sock) {
             throw CommunicationException::socketCreate();
         }
         if (false === @socket_connect($this->sock, $address, $port)) {
             throw CommunicationException::socketConnect($this->sock, $address, $port);
         }
     }
 }