The related code is as follows: $ socketsocket_create (AF_INET, SOCK_STREAM, $ commonProtocol) ordie (& quot; cannotcreatesocketn & quot;); bind the socket to the port $ resultsocket_bind ($ socket, $ host, $ port) ordie (& quot; cannotbindporttosocketn & quot;); start to listen to this port $ resultsocket_listen ($ so socketphp
The related code is as follows: $ socket = socket_create (AF_INET, SOCK_STREAM, $ commonProtocol)
Or die ("cannot create socket \ n"); // bind the socket to the port $ result = socket_bind ($ socket, $ host, $ port) or die ("cannot bind port to socket \ n"); // start listening to this port $ result = socket_listen ($ socket, 4) or die ("cocould not set up socket listen \ n"); // accept the connection, and the other socket handles the communication $ msgsock = socket_accept ($ socket) or die ("cannot accept incoming connection \ n"); if ($ msgsock) {echo date ("Y-m-d H: I: s D ");} // read the information sent from the client $ input = socket_read ($ msgsock, 1024) or die ("cannot read input \ n"); $ input = trim ($ input ); $ output = strrev ($ input ). "The order is reversed \ n"; // process the received information and return it to the client socket_write ($ msgsock, $ output, strlen ($ output )) or die ("cannot write"); // Close the socket connection socket_close ($ msgsock); socket_close ($ socket );
The cannot bind port to socket is displayed on the webpage!