fegg / phpwebsocket

Automatically exported from code.google.com/p/phpwebsocket
0 stars 0 forks source link

the client.php can't connect the server successfully for every time #22

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. refresh the client.php

What version of the product are you using? On what operating system?
WinXP SP3, chrome 9.0.597.19 dev

Please provide any additional information below.
I downloaded the client.php and server.php.I follow the steps to run the 
demo.But,when I refresh the client.php, it can't connect the server 
successfully every time.Does anyone have the same problem?

Original issue reported on code.google.com by blackerj...@gmail.com on 17 Dec 2010 at 11:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Ahh, thanks!,it works. :)

Original comment by blackerj...@gmail.com on 20 Dec 2010 at 4:36

GoogleCodeExporter commented 8 years ago
What did the fix turn out to be?  I'm just starting out with phpwebsocket and 
am noticing the same issue.

Original comment by matt.got...@gmail.com on 20 Jan 2011 at 11:54

GoogleCodeExporter commented 8 years ago
Same issue. I see the following in my command prompt (with different numbers):

Warning: socket_select(): 5 is not a valid Socket resource

Even on the successful connections I see many of these warnings.

Original comment by ryan.e...@gmail.com on 14 Feb 2011 at 8:04

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Found that the handshake sometimes (frequently?) fails.  This will lead to an 
invalid socket error.  Not clear on why the handshake is failing yet however.  
To see if this is what's causing you problems, set $debug on line 11 to true; 
this will get you more error logging in the console.

Original comment by asheetz2...@gmail.com on 9 Mar 2011 at 3:27

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I found the error and a solution too.

Sometimes $numkey1 and/or $numkey2 are bigger than max int value. Therefore, a 
% b returns false values. The ints are replaces by floats, i.e. instead of a % 
b use fmod(a, b).

To the point: Change the if clause of console('failed') to:

if ($spaces1 == 0 || $spaces2 == 0 || fmod($numkey1, $spaces1) != 0 || 
fmod($numkey2, $spaces2) != 0) {

Original comment by pimvande...@gmail.com on 24 Apr 2011 at 10:28