Question

I'm trying to set up a "server" script in PHP, which should run for a limited amount of time in the background. But multiple instances of this script may run at the same time. Unfortunately fsockopen() doesn't let me use the same port at the same time by two different scripts, so others fail in error :(

Is there any way around this?

Was it helpful?

Solution 2

PHP doesnot support multi-threading, but there are alternatives to it, not the best but in slang word- "workable".

And to listen on specific port using php, Use socket_listen, socket_bind, socket_create, etc., functions of php, you may have a look on stream_select functions too... if that helps.

Recommended page Parallel processing in PHP

OTHER TIPS

fsockopen is for client socket and you cannot start a server to listen on specific port with fsockopen

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top