I have written some code in PHP to create a socket and listen for incoming connections. I am trying to do this using a specific port I'm interested in.
Everything is going well, except it opens the listening TCP socket on some random port, instead of the one chosen by me.
I'm running this code on Google Compute Engine (GCE).
Here is the exact php code that I tried:
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
$address = '35.190.179.17';
//bind socket to specified host
socket_bind($socket, $address,54468);
//listen to port
socket_listen($socket);