ds1design / phpwebsocket

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

How do I bind to external address? #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. changing the localhost in line 8 to become some external ip (e.g. 
externalip.no-ip.org)
from ~~~~ $master  = WebSocket("localhost",22222);
to ~~~~~~ $master  = WebSocket("externalip.no-ip.org",22222);

What is the expected output? What do you see instead?
Expected output: 
Server Started : 2010-05-26 18:46:24
Master socket  : Resource id #4
Listening on   : externalip.no-ip.org port 22222

but I see:
Warning: socket_bind(): unable to bind address [49]: Can't assign requested 
address in 
../server.php on line 60
socket_bind() failed.

What version of the product are you using? On what operating system?
r6
osx snow leopard

Thanks a lot!

Original issue reported on code.google.com by james.tr...@gmail.com on 26 May 2010 at 6:50

GoogleCodeExporter commented 9 years ago
I think that you should bind like this instead of 'externalip.no-ip.org':

use '0.0.0.0' to bind to all interfaces
use the physical external ip to bind to that ip

Original comment by sfia.and...@gmail.com on 2 Jun 2010 at 8:26

GoogleCodeExporter commented 9 years ago
make sure you are root ->   sudo su

and bind (like sfia said) to either 0.0.0.0 or at least a valid interface IP on 
the machine. 

Original comment by k1dbl...@gmail.com on 12 May 2011 at 4:52

GoogleCodeExporter commented 9 years ago
Well apparently socket_bind uses 0 for all connections:

http://www.php.net/manual/en/function.socket-bind.php#105774

Original comment by Rybad...@gmail.com on 14 Nov 2011 at 7:02