The following is the corresponding code:
PHP code:
Copy code The code is as follows:
// Set some basic variables
$host = "192.168.1.99";
$port = 1234;
// Set timeout
set_time_limit(0);
// Create a Socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create
socketn");
//Bind Socket to port
$result = socket_bind($socket, $host, $port) or die("Could not bind to
socketn");
// Start listening to the link
$result = socket_listen($socket, 3) or die("Could not set up socket
listenern");
// accept incoming connections
// Another Socket to handle communication
$spawn = socket_accept($socket) or die("Could not accept incoming
connectionn ");
// Get input from the client
$input = socket_read($spawn, 1024) or die("Could not read inputn");
// Clear the input string
$input = trim($input);
//Process client input and return the result
$output = strrev($input) . "n";
socket_write($spawn, $output, strlen ($output )) or die("Could not write
outputn");
// Close sockets
socket_close($spawn);
socket_close($socket);
?>
http://www.bkjia.com/PHPjc/321583.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321583.htmlTechArticleThe following is the corresponding code: PHP code: Copy the code as follows: ? // Set some basic variables $host = "192.168.1.99"; $port = 1234; // Set the timeout set_time_limit(0); // Create...