←Guybrush→ 0 Newbie Poster

Ahoy Sailors!

So, I'm currently trying to under go a Client/Server based application in PHP, I've got a working server script, But it can only handle one connection & at time. To the best of my knowledge you need to make an array. Could anyone give me an example?

Here's my script so far.

$host = "127.0.0.1";
$port = 220;
set_time_limit(0);
// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
$result = socket_listen($socket, 3) or die("Could not set up socket listener\n");
// Networking area, Creating, Binding & finally listing
while (7>0){
$spawn = socket_accept($socket);
$out = "1:Ahoy Sailor!";
socket_write($spawn, $out, strlen ($out));
echo "Sent";
sleep(1);
}
?>

Thanks Bye!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.