Home arrow PHP arrow Page 2 - Socket Programming With PHP

Putting It All Together - PHP

You might not know this, but PHP comes with a very capable socketprogramming API. These socket functions now include almost everything youwould need for socket-based client-server communication over TCP/IP, andcan be easily deployed to build simple network applications. Find out more,inside.

TABLE OF CONTENTS:
  1. Socket Programming With PHP
  2. Putting It All Together
  3. Fortune's Fool
  4. Looping The Loop
  5. On Web-bed Feet
  6. Different Strokes
  7. POP Goes The Weasel
  8. Access Denied
  9. Game Over
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 204
February 05, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
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:

$ /usr/local/bin/php -q server.php
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:

$ telnet 192.168.1.99 1234 Trying 192.168.1.99... Connected to medusa. Escape character is '^]'. jack and the beanstalk klatsnaeb eht dna kcaj Connection closed by foreign host.


 
 
>>> More PHP Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: