PHP
  Home arrow PHP arrow Emulating a Basic Web Server with Sock...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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? 
PHP

Emulating a Basic Web Server with Sockets in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


       · In this last tutorial of the series, the TCP server that was previously built is...
     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT