Multiple TCP socket requests in PHP

Is it possible to accept multiple requests (in parallel) with a socket server built in PHP? If possible, how?

+2


source to share


1 answer


A regular PHP script cannot receive multiple requests. But if you really plan on creating a socket server (run as a cmdline PHP script) then yes it is possible.

Have a look at http://pear.php.net/package/Net_Server - it's already ready for this. In particular, it uses functions pcntl

to fork multiple processes to deal with individual TCP requests.



Another option would be http://nanoserv.si.kz/ , which has a few more features.

+1


source







All Articles