The following code is used:
PHP code:
Copy codeThe Code is as follows:
<?
// Set some basic variables
$ Host = "192.168.1.99 ";
$ Port = 1234;
// Set the timeout value
Set_time_limit (0 );
// Create a Socket
$ Socket = socket_create (AF_INET, SOCK_STREAM, 0) or die ("cocould not create
Socket \ n ");
// Bind the Socket to the port
$ Result = socket_bind ($ socket, $ host, $ port) or die ("cocould not bind
Socket \ n ");
// Start listening Link
$ Result = socket_listen ($ socket, 3) or die ("cocould not set up socket
Listener \ n ");
// Accept incoming connections
// Another Socket for communication
$ Spawn = socket_accept ($ socket) or die ("cocould not accept incoming
Connection \ n ");
// Obtain client input
$ Input = socket_read ($ spawn, 1024) or die ("cocould not read input \ n ");
// Clear the input string
$ Input = trim ($ input );
// Process client input and return results
$ Output = strrev ($ input). "\ n ";
Socket_write ($ spawn, $ output, strlen ($ output) or die ("cocould not write
Output \ n ");
// Disable sockets
Socket_close ($ spawn );
Socket_close ($ socket );
?>