PHP
  Home arrow PHP arrow Emulating a Basic Web Server with Sockets in PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Emulating a Basic Web Server with Sockets in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2006-06-05


    Table of Contents:
  • Emulating a Basic Web Server with Sockets in PHP
  • Taking a quick look at the previous TCP server
  • Emulating a Web server
  • Putting the Web server to work

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Emulating a Basic Web Server with Sockets in PHP
    ( Page 1 of 4 )

    Do you think that programming sockets with PHP is really hard work? Not at all. If you’re still not convinced, read this final part of the series “Handling sockets with PHP.” In three parts, this series shows how to work with low-level sockets in PHP. It introduces some of the typical tasks, such as creating sockets, as well as reading and writing socket data.

    Introduction

    For those who haven’t yet read the second tutorial of this series, allow me to describe in a few words the topics I treated in it. Since using sockets in PHP is a pretty straightforward experience, in the previous article I explained how to create a basic TCP server, which was capable of handling multiple requests coming from the same client application. In this way I eliminated a considerable limitation exposed in the first article.

    Despite the rather primitive functionality of the mentioned TCP server, I hope the example I developed before served as a way for you to get a more intimate grounding in how to program low-level sockets in PHP, and of course contributed to expanding your general knowledge of PHP programming.

    Also, this sample TCP server used some of the typical socket-related PHP functions, in order to create the corresponding end-point communication channels, as well as handling streams of data for reading and writing client input. With reference to demonstrating how to get the server working, I used Microsoft’s Telnet application included in Windows XP, but because of the versatility of the TCP server, you can use your own client program without having to modify the original socket application.

    Having reminded you of the key points regarding the sample TCP server I created in the previous tutorial, it’s time to pay attention to the subject of this final part of the series. In this article, I’ll show you how to use low-level sockets to emulate the functionality of a basic Web server on your own testing machine.

    Want to see how this server will be created? Fine, let’s do it together!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek