socket_bind():无法绑定地址[99](Ubuntu的在Amazon EC2) [英] socket_bind(): unable to bind address [99] (Ubuntu on Amazon EC2)
问题描述
我试图使用套接字在一个EC2实例,但是当我尝试运行code,我得到了以下错误:
PHP的警告:socket_bind():无法绑定地址[99]:不能 在sockets_test.php在线45分配请求的地址
下面是相关code部分:
$ CFG =新stdClass的();
$ CFG-> chat_serverip ='MY_PUBLIC_EC2_IP';
$ CFG-> chat_serverport ='9111';
$ listen_socket = socket_create(AF_INET,SOCK_STREAM,0))
socket_bind($ listen_socket,$ CFG-> chat_serverip,$ CFG-> chat_serverport)
如果我用127.0.0.1或私有IP这工作得很好。 我安集团拥有的规则:
0〜65535 0.0.0.0/0(TCP)
0-65535 0.0.0.0/0(UDP)
所有0.0.0.0/0(ICMP)
您不能绑定到外部IP,你必须绑定到内部IP,并设置一个规则,以允许该端口,所以当他们连接到外部IP和端口,它就会被重定向到内部IP。
I'm trying to use Sockets on an EC2 Instance, but when I try to run the code I get the following error:
PHP Warning: socket_bind(): unable to bind address [99]: Cannot assign requested address in sockets_test.php on line 45
Here is part of the relevant code:
$CFG = new stdClass();
$CFG->chat_serverip = 'MY_PUBLIC_EC2_IP';
$CFG->chat_serverport = '9111';
$listen_socket = socket_create(AF_INET, SOCK_STREAM, 0))
socket_bind($listen_socket, $CFG->chat_serverip, $CFG->chat_serverport)
This works just fine if I use 127.0.0.1 or the Private IP. My Security Group has the the rules:
0-65535 0.0.0.0/0 (TCP)
0-65535 0.0.0.0/0 (UDP)
ALL 0.0.0.0/0 (ICMP)
You cannot bind to the external IP, you have to bind to the internal IP, and setup a rule to allow that port so when they connect to the external IP and port, it gets redirected to the internal IP.
这篇关于socket_bind():无法绑定地址[99](Ubuntu的在Amazon EC2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!