nanoserv
[ class tree: nanoserv ] [ index: nanoserv ] [ all elements ]

Class: Nanoserv

Source Location: /nanoserv.php

Class Overview


Server / multiplexer class


Author(s):

Variables

Constants

Methods



Class Details

[line 1520]
Server / multiplexer class



Tags:

since:  0.9


[ Top ]


Class Variables

static $child_process =  false

[line 1592]

Are we master or child process ?



Tags:

access:  public

Type:   bool


[ Top ]

static $master_pipe =

[line 1604]

Forked server pipe to the master process



Tags:

access:  public

Type:   NS_Socket


[ Top ]

static $max_forked_processes =  64

[line 1586]

Maximum number of active children before incoming connections get delayed



Tags:

access:  public

Type:   int


[ Top ]

static $nb_forked_processes =  0

[line 1580]

Number of active connection handler processes



Tags:

access:  public

Type:   int


[ Top ]



Class Methods


static method Clear_Timers [line 1880]

static int Clear_Timers( )

Clear all existing timers



Tags:

return:  number of timers cleared
since:  2.0
access:  public


[ Top ]

static method Flush_Write_Buffers [line 1962]

static void Flush_Write_Buffers( )

Flush all write buffers



Tags:

since:  2.0
access:  public


[ Top ]

static method Fork [line 1978]

static int Fork( )

Fork and setup IPC sockets



Tags:

return:  the pid of the created process, 0 if child process
since:  0.9.63
access:  public


[ Top ]

static method Free_Connection [line 1775]

static bool Free_Connection( NS_Connection_Handler $h)

Free an allocated connection



Tags:

since:  0.9
access:  public


Parameters:


[ Top ]

static method Free_Datagram_Handler [line 1815]

static bool Free_Datagram_Handler( NS_Datagram_Handler $h)

Deactivate and free a datagram handler



Tags:

since:  0.9.61
access:  public


Parameters:

NS_Datagram_Handler   $h  

[ Top ]

static method Free_Listener [line 1654]

static bool Free_Listener( NS_Listener $l)

Deactivate and free a previously registered listener

For consistency Free_Listener() will also wrap Nanoserv::Free_Datagram_Handler() if the given object is an instance of NS_Datagram_Handler




Tags:

see:  NS_Listener
see:  NS_Datagram_Handler
since:  0.9
access:  public


Parameters:

NS_Listener   $l  

[ Top ]

static method Free_Shared_Object [line 1849]

static void Free_Shared_Object( NS_Shared_Object $o)

Free a shared object



Tags:

since:  0.9
access:  public


Parameters:

NS_Shared_Object   $o  

[ Top ]

static method Free_Write_Buffers [line 1739]

static void Free_Write_Buffers( int $sid)

Free a registered write buffer



Tags:

since:  0.9
access:  public


Parameters:

int   $sid   socket id

[ Top ]

static method Get_Connections [line 1899]

static array Get_Connections( [bool $include_pending_connect = false])

Get all registered NS_Connection_Handler objects

Note: connections created by fork()ing listeners can not be retreived this way




Tags:

since:  0.9
access:  public


Parameters:

bool   $include_pending_connect  

[ Top ]

static method Get_Listeners [line 1916]

static array Get_Listeners( [bool $include_inactive = false])

Get all registered NS_Listener objects



Tags:

since:  0.9
access:  public


Parameters:

bool   $include_inactive  

[ Top ]

static method Get_Timers [line 1933]

static array Get_Timers( [bool $include_inactive = false])

Get all registered NS_Timer objects



Tags:

since:  2.0.1
access:  public


Parameters:

bool   $include_inactive  

[ Top ]

static method New_Connection [line 1755]

static NS_Connection_Handler New_Connection( string $addr, string $handler_classname, [mixed $handler_options = false])

Register a new outgoing connection



Tags:

see:  NS_Connection_Handler
since:  0.9
access:  public


Parameters:

string   $addr  
string   $handler_classname  
mixed   $handler_options  

[ Top ]

static method New_Datagram_Handler [line 1799]

static NS_Datagram_Handler New_Datagram_Handler( string $addr, string $handler_classname)

Register a new datagram (udp) handler



Tags:

see:  NS_Datagram_Handler
since:  0.9.61
access:  public


Parameters:

string   $addr  
string   $handler_classname  

[ Top ]

static method New_Listener [line 1626]

static NS_Listener New_Listener( string $addr, string $handler_classname, [mixed $handler_options = false])

Register a new listener

For consistency New_Listener() will also wrap Nanoserv::New_Datagram_Handler() if the given addr is of type "udp"




Tags:

see:  NS_Listener
see:  NS_Datagram_Handler
since:  0.9
access:  public


Parameters:

string   $addr  
string   $handler_classname  
mixed   $handler_options  

[ Top ]

static method New_Shared_Object [line 1833]

static NS_Shared_Object New_Shared_Object( [object $o = false])

Register a new shared object

shared objects allow forked processes to use objects stored on the master process if $o is ommited, a new StdClass empty object is created




Tags:

since:  0.9
access:  public


Parameters:

object   $o  

[ Top ]

static method New_Static_Write_Buffer [line 1688]

static NS_Static_Write_Buffer New_Static_Write_Buffer( NS_Socket $socket, string $data, [mixed $callback = false])

Register a new static write buffer

This method is used by NS_Connection_Handler::Write() and should not be called unless you really know what you are doing




Tags:

see:  NS_Connection_Handler::Write()
since:  0.9
access:  public


Parameters:

NS_Socket   $socket  
string   $data  
mixed   $callback  

[ Top ]

static method New_Stream_Write_Buffer [line 1717]

static NS_Stream_Write_Buffer New_Stream_Write_Buffer( NS_Socket $socket, $data, [mixed $callback = false], resource $stream)

Register a new static write buffer

This method is used by NS_Connection_Handler::Write_Stream() and should not be called unless you really know what you are doing




Tags:

see:  NS_Connection_Handler::Write_Stream()
since:  0.9
access:  public


Parameters:

NS_Socket   $socket  
resource   $stream  
mixed   $callback  
   $data  

[ Top ]

static method New_Timer [line 1863]

static NS_Timer New_Timer( float $delay, mixed $callback)

Register a new timer callback



Tags:

since:  0.9
access:  public


Parameters:

float   $delay   specified in seconds
mixed   $callback   may be "function" or array($obj, "method")

[ Top ]

static method Run [line 2031]

static array Run( [float $time = NULL], [array $user_streams = NULL])

Enter main loop

The $time parameter can have different meanings:

  • int or float > 0 : the main loop will run once and will wait for activity for a maximum of $time seconds
  • 0 : the main loop will run once and will not wait for activity when polling, only handling waiting packets and timers
  • int or float < 0 : the main loop will run for -$time seconds exactly, whatever may happen
  • NULL : the main loop will run forever




Tags:

return:  the user streams with pending data
since:  0.9
access:  public


Parameters:

float   $time   how much time should we run, if omited nanoserv will enter an endless loop
array   $user_streams   if specified, user streams will be polled along with internal streams

[ Top ]

static method Set_Max_Children [line 1951]

static void Set_Max_Children( int $i)

Set the maximum number of allowed children processes before delaying incoming connections

Note: this setting only affect and applies to forking listeners




Tags:

since:  2.0
access:  public


Parameters:

int   $i  

[ Top ]


Class Constants

VERSION =  "2.1.2-dev"

[line 1526]

nanoserv current version number


[ Top ]



Documentation generated on Thu, 10 May 2012 22:01:23 +0200 by phpDocumentor 1.4.4