Re: [PHP] socket multithreading problem
[email protected] (Rasmus Lerdorf)
| Newsgroups | php.general |
|---|---|
| Message-ID | <[email protected]> |
On 7/27/10 7:04 AM, Ãmit CAN wrote: > I use PHP socket programming and I wish multithreading operation of the socket . > When I have many requests on this socket , before the first one request is anwered , the second request is not aswered till the first one is finished. > How can both requests work together without waiting each other ? I assume you mean you have multiple sockets and not just one? If it is just one, you just need to write a little state machine that keeps track of your requests since only one thing can happen at a time on a single socket. If you have multiple sockets you should be looking at http://php.net/socket_select and not threads. Threads and/or pcntl processes would be a very inefficient way to deal with something as simple as reading messages asynchronously from many sockets. -Rasmus