Re: Re: php websocket server and clients

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I modified my script to

<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

$server = stream_socket_server("tcp://127.0.0.1:8080");

for ($i = 1; $i <= 50; $i++) {
    var_dump($i);
    stream_socket_client("tcp://127.0.0.1:8080");
    //stream_socket_accept($server);
}

but it doesn't show any error. Am I doing something wrong it turning on error reporting?

On 19/05/2015 23:47, Christoph Becker wrote:
Marco Perone wrote:

I'm trying to build a script that creates a websocket server and some
clients that connects to it.

A huge synthesis of the code could be:

|$server=  stream_socket_server("tcp://127.0.0.1:8080");

for  ($i=  1;  $i<=  50;  $i++)  {
     var_dump($i);
     stream_socket_client("tcp://127.0.0.1:8080");
}|



everything is fine for the first 35 clients, then the connections start
to slow down and they happen almost one per second.

What is the reason for these delays? Is it a configuration setting?
Something due to my operative system?

I'm using PHP 5.6.4-4 on ubuntu 15.04
I suggest you turn on error_reporting(-1).  Then you'll probably see
that the client can't connect, and hits a timeout.  At least on my
German Windows box after 32 clients I get:

| Warning: stream_socket_client(): unable to connect to
| tcp://127.0.0.1:8080 (Es konnte keine Verbindung hergestellt werden, |
da der Zielcomputer die Verbindung verweigerte.)

[A connection couldn't be established, because the host refused the
connection.]

There seems to be a limit on allowed TCP connections; switching to UDP
works fine, though.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux