Re: ADVANCED PHP (SOCKETS) MULTIPLEXING SERVER
| From: | J Smith | Date: | Thu, 15 Aug 2002 14:59:39 +0000 |
| Subject: | Re: ADVANCED PHP (SOCKETS) MULTIPLEXING SERVER | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-86869@lists.php.net to get a copy of this message | ||
Questions like this should be posted to php.general, not php.dev -- php.dev
is for developing PHP itself; php.general is for developing WITH PHP.
That aside, attached is a simple example of setting up a multiplexer with
socket_select(). The example creates a [very] small chat server -- just
start up the server and try connecting with telnet to localhost on port
10000 with a couple of terminals. You should be able to send messages from
terminal to terminal.
Note that the example doesn't do a lot of error checking, and is pretty
hacked together and not too pretty. But it's a decent example.
J
Gustavo Almeida wrote:
> Dear php-dev,
>
> Hi, I'm here again with another doubt. Now, I know that I have to
> use socket_select() before the socket_accept(), but what I can't
> understand is how to "store" or handle many clients yet, my app
> has a lot of socket_write() and socket_read() functions, and
> intaction with DB (Postgres), I guess am I a little confuse,
> anybody help?
>
Attachment: [text/x-c++src] echo-serv.php
Attachment: [text/x-c++src] echo-serv.php