I am trying to create a tcp server on an ec2 machine with ubuntu platform. While php is running fine from the index.php file, the code returns false at following command:
socket_create(AF_NET,SOCK_STREAM,SQL_TCP);
Although it returns false, socket_last_error() returns 0. I checked output of phpinfo(), and the table shows sockets as enabled. I verified the security group settings from the aws console. It allows ssh and http traffic.
Please suggest what I might have missed in the configurations of the machine.
Thanks in advance.
As per the documentation of socket_create, the correct parameters are:
socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
PS: notice typo in AF_INET and SOL_TCP
I just tried it on a fresh aws t1.micro instance and it worked. (Pls note that you might have to add rules in security group's inbound rules if you want external world to communicate on the opened tcp socket).