Here is the corresponding code:
PHP Code:
Copy CodeThe code is as follows:
Set some basic variables
$host = "192.168.1.99";
$port = 1234;
Setting the time-out period
Set_time_limit (0);
Create a socket
$socket = Socket_create (af_inet, sock_stream, 0) or die ("Could not create
Socket\n ");
Bind socket to Port
$result = Socket_bind ($socket, $host, $port) or Die ("Could not bind to
Socket\n ");
Start listening links
$result = Socket_listen ($socket, 3) or Die ("Could not set up socket
Listener\n ");
Accept Incoming Connections
Another socket to handle communication
$spawn = socket_accept ($socket) or Die ("Could not accept incoming
Connection\n ");
Get input from the client
$input = Socket_read ($spawn, 1024x768) or Die ("Could not read input\n");
Empty the input string
$input = Trim ($input);
Processing client input and returning results
$output = Strrev ($input). "\ n";
Socket_write ($spawn, $output, strlen ($output)) or Die ("Could not write
Output\n ");
Close sockets
Socket_close ($spawn);
Socket_close ($socket);
?>
http://www.bkjia.com/PHPjc/321583.html www.bkjia.com true http://www.bkjia.com/PHPjc/321583.html techarticle here is the corresponding code: PHP code: Copy the Code as follows:?//Set some basic variables $host = "192.168.1.99"; $port = 1234;//Set timeout time set_time_limit (0);//Gen. .