HI,
I am writing a IRC server that will connect to the other server, communicate with it and perform functions // Already done
The problem now is I wish to let the server open another socket to a client, when the client request for a direct-client2client connection for chat.
A simplified version of my program
$socket[main] = @fsockopen($uplink[host], $uplink[port], &$errno, &$errstr, 2);
do {
/ Reads 2KB of data into a temp var /
//$read[buf]= "";
//$read[res] = socket_read($socket[main],1028,PHP_NORMAL_READ);
/ Checks for error /
//echo "$read[res]";
$read[res] = trim(fgets($socket[main3], 2056));
if ($read[res] < 0) {
$socket_strerror = socket_strerror($read[res]);
debug("read() failed: reason: $socket_strerror");
if (strstr($socket_strerror, "peer")) {
die("Connection Died\n");
}
continue;
}
if (!$read[res] == trim($read[res])) {
continue;
}
$params = explode(" ", $read[res]);
proc($read[res]);
}
continue;
} while (!feof($socket[main])); <- I wish to spawn another socket in this loop. Will I be allowed to do so? I might need to spawn more than 1 socket at times. Does php allow me to do that? please guide me. THank u in advance.