Re: socket multithreading problem

From: Date: Thu, 29 Jul 2010 19:27:43 +0000
Subject: Re: socket multithreading problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-307224@lists.php.net to get a copy of this message
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

« previous php.general (#307224) next »