Now, how about seeing it in action? Since this script generates an "always-on" socket, it isn't a good idea to run it via your Web server; instead, you might prefer to run it from the command line via the PHP binary: In case you don't have a PHP binary, it's fairly easy to compile one - just follow the installation instructions for compiling a static Apache module (these instructions are available in the PHP distribution), but omit the "--with-apache" parameter to the "configure" script. Note the additional -q parameter to PHP - this tells the program to suppress the "Content-Type: text/html" header that it usually adds when executing a script (I don't need this header here because the output of this script isn't going to a browser). Once the script has been executed and the socket server is active, you can simply telnet to it using any standard telnet application, and send it a string of characters as input. The server should respond with the reversed string, and then terminate the connection. Here's what it looks like:
blog comments powered by Disqus |