Home arrow PHP arrow Emulating a Basic Web Server with Sockets in PHP

Emulating a Basic Web Server with Sockets in PHP

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.

TABLE OF CONTENTS:
  1. Emulating a Basic Web Server with Sockets in PHP
  2. Taking a quick look at the previous TCP server
  3. Emulating a Web server
  4. Putting the Web server to work
By: Alejandro Gervasio
Rating: starstarstarstarstar / 10
June 05, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

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: