Ver Fonte

Don't pass port if using a file

Nathaniel van Diepen há 7 anos atrás
pai
commit
4ca5828900
1 ficheiros alterados com 12 adições e 2 exclusões
  1. 12 2
      Net/socket.class.php

+ 12 - 2
Net/socket.class.php

@@ -71,12 +71,22 @@
 			$this->socket = socket_create(constant("AF_{$this->dsn['protocol']}"), constant("SOCK_{$this->dsn['type']}"), is_null($this->dsn['protocol']) ? 0 : getprotobyname($this->dsn['protocol']));
 			$this->throw_if($this->socket);
 			if($this->socket_type == static::SERVER){
-				$this->throw_if(socket_bind($this->socket, $this->address, $this->port));
+				if(is_null($this->port)){
+					socket_bind($this->socket, $this->address);
+				}else{
+					$res = socket_bind($this->socket, $this->address, $this->port);
+				}
+				$this->throw_if($res);
 				$this->fire('bind', $this);
 				$this->throw_if(socket_listen($this->socket, $this->max_connections));
 				$this->fire('listen', $this);
 			}elseif($this->socket_type == static::CLIENT){
-				$this->throw_if(socket_connect($this->socket, $this->address, $this->port));
+				if(is_null($this->port)){
+					socket_connect($this->socket, $this->address);
+				}else{
+					$res = socket_connect($this->socket, $this->address, $this->port);
+				}
+				$this->throw_if($res);
 			}else{
 				throw new \Exception("Invalid socket type {$this->socket_type}");
 			}