[TASK] Now using DIRECTORY_SEPERATOR for the few paths we have.
This commit is contained in:
@@ -91,7 +91,7 @@ class Socket_SocketHandler {
|
||||
public function connect($address, $port) {
|
||||
if($this->isConnected === TRUE) throw new Exception_SocketException("Socket is already connected!", 1289663170);
|
||||
$result = socket_connect($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$this->isConnected = TRUE;
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@ class Socket_SocketHandler {
|
||||
public function bind($address, $port) {
|
||||
if($this->isBound === TRUE) throw new Exception_SocketException("Socket is already bound!", 1289663212);
|
||||
$result = socket_set_option($this->socket, SOL_SOCKET, SO_REUSEADDR, 1);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$result = socket_bind($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$this->isBound = TRUE;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class Socket_SocketHandler {
|
||||
public function listen() {
|
||||
if($this->isBound === FALSE) throw new Exception_SocketException("Cannot listen on unbound socket!", 1289663220);
|
||||
$result = socket_listen($this->socket);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$this->isListening = TRUE;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class Socket_SocketHandler {
|
||||
if($this->isBound === FALSE) throw new Exception_SocketException("Cannot accept connections from unbound socket!", 1289663239);
|
||||
if($this->isListening === FALSE) throw new Exception_SocketException("Cannot accept connections from socket that is not listening!", 1289663241);
|
||||
$accept = socket_accept($this->socket);
|
||||
if($accept === FALSE) $this->error();
|
||||
if($accept === FALSE) $this->handleSocketError();
|
||||
return $accept;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ class Socket_SocketHandler {
|
||||
public function getRemoteName() {
|
||||
if($this->isConnected === FALSE) throw new Exception_SocketException("Socket not connected, cannot retrieve remote name!", 1289928192);
|
||||
$result = socket_getpeername($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
return $address . ":" . $port;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ class Socket_SocketHandler {
|
||||
public function getLocalName() {
|
||||
if($this->isBound === FALSE ^ $this->isConnected === FALSE) throw new Exception_SocketException("Socket is not bound or connected, no local name available!", 1289928256);
|
||||
$result = socket_getsockname($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
return $address . ":" . $port;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class Socket_SocketHandler {
|
||||
*/
|
||||
public function write($data) {
|
||||
$result = socket_write($this->socket, $data);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ class Socket_SocketHandler {
|
||||
*/
|
||||
public function read($length = 16384) {
|
||||
$result = socket_read($this->socket, $length, PHP_BINARY_READ);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -201,11 +201,11 @@ class Socket_SocketHandler {
|
||||
usleep(100000);
|
||||
if($this->isConnected === TRUE) {
|
||||
$result = socket_shutdown($this->socket);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
}
|
||||
if(is_resource($this->socket)) {
|
||||
$result = socket_close($this->socket);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
}
|
||||
$this->isConnected = FALSE;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ class Socket_SocketHandler {
|
||||
* @throws Exception_SocketException
|
||||
* @return void
|
||||
*/
|
||||
protected function error() {
|
||||
protected function handleSocketError() {
|
||||
if(is_resource($this->socket) === FALSE) throw new Exception_SocketException("No socket resource available!", 1290954177);
|
||||
$errno = socket_last_error($this->socket);
|
||||
$error = socket_strerror($errno);
|
||||
|
||||
Reference in New Issue
Block a user