[TASK] Added function for clients, so they're able to send initial data right after connecting to a server.

[TASK] Restructured parts of the core to support sending data right after connecting.
[TASK] Adapted core part for automatic reconnect to support sending initial data, too.
This commit is contained in:
Jan Philipp Timme
2011-06-25 22:13:53 +00:00
parent 4c9f5ba7f3
commit 2c5e520c9f
11 changed files with 159 additions and 66 deletions
+3 -3
View File
@@ -71,8 +71,8 @@ class Socket_SocketPool {
* @return ressource
*/
public function createTcpSocket($IPv6 = FALSE) {
$Domain = ($IPv6) ? AF_INET6 : AF_INET;
$socket = socket_create($Domain, SOCK_STREAM, SOL_TCP);
$domain = ($IPv6) ? AF_INET6 : AF_INET;
$socket = socket_create($domain, SOCK_STREAM, SOL_TCP);
socket_set_block($socket);
if($socket === FALSE) throw new Exception_SocketException("socket_create() failed!", 1290273709);
$this->addSocket($socket);
@@ -90,7 +90,7 @@ class Socket_SocketPool {
*/
public function select($read, $write, $except, $timeout = NULL) {
$n = socket_select($read, $write, $except, $timeout);
if($n === FALSE) throw new Exception_SocketException("socket_select() failed!", 1290273693);
if($n === FALSE) throw new Exception_SocketException("socket_select() failed! - Error: " . socket_strerror(socket_last_error()), 1290273693);
if($n === 0) return array("read" => array(), "write" => array(), "except" => array());
return array("read" => $read, "write" => $write, "except" => $except);
}