PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Debug   SuperSocket   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: SuperSocket
Handle multiple TCP socket connections
Author: By
Last change:
Date: 16 years ago
Size: 440 bytes
 

Contents

Class file image Download
<?php

/*

Simple "echo back" TCP server.

*/

include("supersocket.class.php");

##### FIRST WITH OUR CALLBACKS #####
function newdata($socket_id, $channel_id, $buffer, &$obj)
    {
       
$obj->write($socket_id, $channel_id, $buffer);
    };

$socket = new SuperSocket(array("*:10000")); // will listen on ALL IPs over port 10000
$socket->assign_callback("DATA_SOCKET_CHANNEL", "newdata");
$socket->start();
$socket->loop();

?>