Jump to content

Multiple Socket creation loop


Cyberslime

Recommended Posts

You can use an array,

for ( $socknumber = 1; $socknumber <= 20; $socknumber += 1) {
$sck[] = fsockopen ($site, 80, $errno, $errstr, 30);
}

/* Then access them using foreach() */

foreach($sck As $socket)
{
// Do something with $socket
}

 

 

 

I'm not being able to put it to work, can you leave an example that starts 5 sockets and then sends data with them? I'd also like to loop the data sending infinite times.

Example: Socket 1 sends 1, socket 2 sends 2, socket 3 => 3, sock 4 => 4, sock 5 => 5

Data received by server:

1

2

3

4

5

1

2

3

4

5

1

2

3

4

5

etc...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.