i'm using this mishmash of code:
<?
error_reporting (4);
set_time_limit (0);
ob_implicit_flush ();
echo "Server Started...<br />";
$address = '192.168.0.5';
$port = 4800;
if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($sock) . "\n";
}
if (socket_setopt($sock,SOL_SOCKET,SO_REUSEADDR,1)) {
echo "<br />socket options set!";
}
if (($ret = socket_bind ($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror ($ret) . "\n";
}
if (($ret = socket_listen ($sock, 5)) < 0) {
echo "socket_listen() failed: reason: " . socket_strerror ($ret) . "\n";
}
while(1) {
if (!pcntl_fork()) { // this is the child process
if (($loginsock = socket_accept($sock)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror ($loginsock) . "\n";
break 2;
}
echo "<br/>In a child process..";
$data = "Connected!";
socket_write($loginsock, $data, strlen($data));
}
}
socket_close ($sock);
?>
I can telnet to it fine with one client. I can open another telnet session and telnet into it with that simultaniously as well. However, if i open a third, the first gets disconnected and so on. It will only allow 2 simultanious connections...
can anyone explain to me why and how to fix this?
thanks!