Jump to content

how do I start this socket server?


unomateo

Recommended Posts

I'm trying to start a socket on my server.
I have installed pear net_server and I am using the example from pear:

[code]
#!/usr/bin/php
<?php
    // server base class
    require_once 'Net/Server.php';
   
    // base class for the handler
    require_once 'Net/Server/Handler.php';

/**
* simple example that implements a talkback.
*
* Normally this should be a bit more code and in a separate file
*/
class Net_Server_Handler_Talkback extends Net_Server_Handler
{
  /**
    * If the user sends data, send it back to him
    *
    * @access  public
    * @param    integer $clientId
    * @param    string  $data
    */
    function    onReceiveData( $clientId = 0, $data = "" )
    {
        $this->_server->sendData( $clientId, "You said: $data" );
    }
}
   
    // create a server that forks new processes
    $server  = &Net_Server::create('fork', 'xx.xx.xx.xx', 9090);
   
    $handler = &new Net_Server_Handler_Talkback;
   
    // hand over the object that handles server events
    $server->setCallbackObject($handler);
   
    // start the server
    $server->start();
?>
[/code]

when I try to run this using ssh with this command:
/usr/bin/php  /home/website/public_html/sockets/server.php
I get this response:
PEAR constructor called, class=net_server_driver_fork

I do not think the server has started???
from example I see on the internet, I should be able to use telnet to connect to the port and everything I type in telnet should be echoed back.
I do not have telnet available on the server, so I'm trying to ssh to connect but I cannot...

So, how do I start the socket to connect with ssh?

I'm trying to make a simple chat server.


Link to comment
https://forums.phpfreaks.com/topic/31521-how-do-i-start-this-socket-server/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.