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)