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?

有帮助吗?

解决方案 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

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top