PHP Classes

Simple Server: Implement TCP socket servers

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 53%Total: 1,580 All time: 2,495 This week: 560Up
Version License Categories
simpleserver 1.0GNU General Publi...Networking
Description 

Author

This class provides an interface for implementing TCP socket servers by handling the connections, sending and retrieving data to the clients that connect to the server.

The class has the ability buffer the data received from the clients. The data may be returned to the calling script in smaller chunks split by a given divider character sequence. This is convinient for line oriented protocols with which the line break and line feed character sequence is used to delimit the protocol commands. But in your opinion you can choose any character to split or deactivate splitting.

You can build servers that handle the protocol dialogs in loops, but you can also create servers that are just waiting for one connection and then they shut down when they are that with that connection.

Now there is also a second class inside this package (SimpleServerCallback) which allows you to create simplified callback based TCP Deamons. It is very easy to handle this way, a example for this is also included. But you should note that the Callback Interface is testing and not stable yet!


Three examples are included:
o A simple ECHO server
o A simple Time server
o A funny FOO server, based on callbacks..

Picture of MC Breit
Name: MC Breit <contact>
Classes: 7 packages by
Country: Germany Germany
Age: 124
All time rank: 31114 in Germany Germany
Week rank: 180 Up12 in Germany Germany Up
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files (5)  
File Role Description
Accessible without login Plain text file echo_server.php Example A Simple ECHO Server, acts interactive to the clients input - Demonstrates the "connection keep alive" routine..
Accessible without login Plain text file foo_callback_server.php Example A funny FOO server, demonstrates how to use the Callback based interface of SimpleServerCallback.class.php
Plain text file SimpleServer.class.php Class The main class - Providing all the functions needed..
Plain text file SimpleServerCallback.class.php Class Derivation of the main class, providing a Callback based interface.
Accessible without login Plain text file time_server.php Example A simple timeserver, prints out the local server time in ISO 8601 - Demonstrates the "connection close" routine..

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,580
This week:0
All time:2,495
This week:560Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:79%StarStarStarStar
Tests:-
Videos:-
Overall:53%StarStarStar
Rank:2170