Re: Multi-threaded port listener
| From: | Alister Bulman | Date: | Fri, 28 Apr 2006 20:59:47 +0000 |
| Subject: | Re: Multi-threaded port listener | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235043@lists.php.net to get a copy of this message | ||
On 28/04/06, René Fournier <m5@renefournier.com> wrote:
Anyone find any good tutorials, code samples, etc. on such a thing? Basically, I want to write server (in PHP) that listeners on a particular port, and spins off a thread/process (essentially, execute a separate script) for each incoming connection. There won't be a lot of data to process, but there will be many simultaneous connections— upwards of 1000s of connections (each spun off as seperate threads).it's possible in PHP - but you'll unlikely want to do it as seperate processes, even as threads (besides, PHP doesn't have threads?) Check out http://php.net/stream_select and http://netevil.org/node.php?uuid=427d6d12-c107-9816-7428-27d6d128f5e5 With stream_select and the other stream handling software, there are some guys writing a mail server in PHP. I've got a script opening a dozen outbound connections to an external website to push it data myself, and that saves a lot of time rather than waiting for a connection to come back from fopen/fsockopen Alister