PHP Classes

File: echoer.php

Recommend this page to a friend!
  Classes of Joshua hatfield   floSocket   echoer.php   Download  
File: echoer.php
Role: Example script
Content type: text/plain
Description: 3 Line Echoer Example
Class: floSocket
Implement TCP socket server scripts
Author: By
Last change:
Date: 19 years ago
Size: 1,637 bytes
 

Contents

Class file image Download
<?
/***************************************************************************
 * Original floSocket copyright (C) 2005 by Joshua Hatfield. *
 * *
 * In order to use any part of this floSocket Class, you must comply with *
 * the license in 'license.doc'. In particular, you may not remove this *
 * copyright notice. *
 * *
 * Much time and thought has gone into this software and you are *
 * benefitting. We hope that you share your changes too. What goes *
 * around, comes around. *
 ***************************************************************************

In this example, I will show that floSocket can in fact be implemented using
only three lines of code minus any comment lines you may need of course ;-).

This example creates a simple echoer on port 9999.
*/

// Line one, include the class file.
include("floSocket.php");

// Line two, create a class instance.
$mySocket = new floSocket(false, 9999);

// Line three, start the listener.
$mySocket->start();
/*
Because there is no event function specified for SOCKET_EVENT_NEWDATA, all
received data is spit back to the connection. Otherwise, this example is
completely silent.

There are a number of things that you will PROBABLY want to add, this example
is not for that. Please see simple.php for a more comprehensive example.
*/
?>