Jump to content

So I am making a PHP based server...


zellfaze

Recommended Posts

First let me introduce myself, I am Zell and I am a fairly fequent person on the phpfreaks IRC channel on Freenode.  That is where it was suggested that I come here.

 

I am working on building a MUD server in PHP, and I have the main server application written.  I am just having a few problems with the socket stuff.  My sockets will not bind to anything other than 127.0.1.1.

 

When I run my server I get the output.

web@Zinka-lnx:/media/VPC/public_html/test/mud$ sudo php server.php

Warning: socket_bind(): unable to bind address [99]: Cannot assign requested address in /media/VPC/public_html/test/mud/server.php on line 16
Could not bind to address
Cannot assign requested address
web@Zinka-lnx:/media/VPC/public_html/test/mud$ 

 

Line 16 has on it.

socket_bind($sock, $address, $port) or die("Could not bind to address\n" . socket_strerror(socket_last_error($sock)) ."\n");

 

The server starts up and works just fine if $address is set to 127.0.0.1 but if I set it to my public IP address it generates that error.

 

I just got into socket programming a few days ago, so I really don't know where to go from here...

Link to comment
https://forums.phpfreaks.com/topic/139061-so-i-am-making-a-php-based-server/
Share on other sites

I am behind a wireless router, all the ports are forwarded to me.  The IP address I am trying to use is the IP address our ISP assigned to us, not the one the router assigned to me.

 

If you need said IP address do a lookup on zellfaze.crabdance.com

 

I would rather not post the IP address, but the domain that points here should be fine.

My point was I believe the IP you need to use has to be assigned actually to the NIC, not to the Router.  So it will probably work fine with localhost (127.0.0.1) or your internal IP (192.168.1.x) but not your External IP set to your Router.

 

That is just my thoughts on why it won't bind.

 

Don't you want it to bind to the local IP, and let the Port Forwarding on the router do it's work?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.