-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Fatal error: Uncaught exception 'socketException' with message 'Could not
bind socket to [0 - 2001]: Address already in use' in
/home/www/site/socket.php5:56 Stack trace: #0
/home/www/site/socketServer.php5(27): socket->__construct(0, 2001, 2, 1, 6)
#1 /home/www/site/socketDaemon.php5(28):
socketServer->__construct('httpdServerClie...', 0, 2001) #2
/home/www/site/httpd.php5(32): socketDaemon->create_server('httpdServer',
'httpdServerClie...', 0, 2001) #3 {main} thrown in
/home/www/site/socket.php5 on line 56
how can we get it to work?????
#!/usr/bin/php -Cq
<?
ini_set('mbstring.func_overload', '0');
ini_set('output_handler', '');
error_reporting(E_ALL | E_STRICT);
@ob_end_flush();
//set_time_limit(0);
include("socket.php5");
include("httpServer.php5");
$daemon = new socketDaemon();
$server = $daemon->create_server('httpdServer', 'httpdServerClient', 0, 2001);
$daemon->process();
$client = $daemon->create_client('myClientClass', 'mysite.com', 80);
class myClientClass extends socketClient {
public function on_read()
{
// handle incomming data which is in $this->read_buffer, forexample the
// following looks for \r\n, then parses the complete instruction to
'handle_request'
while (($pos = strpos($this->read_buffer,"\r\n")) !== FALSE) {
$string = trim(substr($this->read_buffer, 0, $pos + 2));
$this->read_buffer = substr($this->read_buffer, $pos + 2);
$this->handle_request($string);
}
}
// other event hooks that exist:
public function on_connect() { echo "contected"; }
public function on_disconnect() { echo "disconected";}
//public function on_read() {}
public function on_write() {}
public function on_timer() {}
}
Original issue reported on code.google.com by andrew.w...@gmail.com on 16 Nov 2007 at 10:31
Reactions are currently unavailable