Hello.
This is a follow up on a previous thread: http://phpbuilder.com/board/showthread.php?t=10375449
I'm trying to redirect a socket connection via browser to another script or page but, I'm having a lot of problems trying to do it. I don't know if it can be done. Please guide me to where I can get some input on it. I've google about it and nothing exactly...
The socket file looks like this:
$host = "172.16.0.3";
$port = "200";
// don't timeout!
set_time_limit(0);
// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP ) 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 for connections
$result = socket_listen($socket, 3) or die("Could not set up socket listener\n");
while( true ){
// accept incoming connections
// spawn another socket to handle communication
$spawn = socket_accept($socket) or die("Could not accept incoming connection\n");
// read client input
$input = socket_read($spawn, 1024) or die("Could not read input\n");
// clean up input string
$input = trim($input);
// reverse client input and send back
$output = strrev($input) . "\n";
header('Location: http://www.cnn.com/');
$output = "hello there.. you're connected";
socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n");
}
// close sockets
socket_close($spawn);
socket_close($socket);
?>
I put in the browser's addr bar: http://172.16.0.3:200
and get "hello there.. you're connected"...
Any suggestions?
Thanks in advanced for your help.