Package pyxmpp2 :: Package server :: Module listener :: Class TCPListener
[hide private]

Class TCPListener


Listens on a TCPSocket calling a function on incoming connection.
Nested Classes [hide private]

Inherited from mainloop.interfaces.IOHandler: __metaclass__

Instance Methods [hide private]
 
__init__(self, family, address, target)
Initialize the TCPListener object and create the socket.
 
__del__(self)
 
close(self)
Close the channell immediately, so it won't expect more events.
IOHandlerPrepareResult
prepare(self)
When connecting start the next connection step and schedule next prepare call, when connected return HandlerReady()
 
fileno(self)
Return file descriptor to poll or select.
 
is_readable(self)
Returns: True when the I/O channel can be read
 
wait_for_readability(self)
Stop current thread until the channel is readable.
 
is_writable(self)
Returns: True when the I/O channel can be written to
 
wait_for_writability(self)
Stop current thread until the channel is writable.
 
handle_write(self)
Handle the 'channel writable' state.
 
handle_read(self)
Accept any incoming connections.
 
handle_hup(self)
Handle the 'channel hungup' state.
 
handle_err(self)
Handle an error reported.
 
handle_nval(self)
Handle an 'invalid file descriptor' event.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __abstractmethods__ = frozenset([])
  _abc_negative_cache_version = 27
Instance Variables [hide private]
socket object _socket = None
the listening socket
threading.RLock _lock
thread synchronisaton lock
callable _target
function to be called with accepted connection.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, family, address, target)
(Constructor)

 
Initialize the TCPListener object and create the socket.
Parameters:
  • family - address family (socket.AF_INET or socket.AF_INET6)
  • address - address to listen on (address, port)
  • target - function to call on an accepted connection
Overrides: object.__init__

close(self)

 
Close the channell immediately, so it won't expect more events.
Overrides: mainloop.interfaces.IOHandler.close
(inherited documentation)

prepare(self)

 
When connecting start the next connection step and schedule next prepare call, when connected return HandlerReady()
Returns: IOHandlerPrepareResult
HandlerReady() if there is no need to call prepare again or PrepareAgain() otherwise.
Overrides: mainloop.interfaces.IOHandler.prepare

fileno(self)

 
Return file descriptor to poll or select.
Overrides: mainloop.interfaces.IOHandler.fileno

is_readable(self)

 
Returns:
True when the I/O channel can be read
Overrides: mainloop.interfaces.IOHandler.is_readable
(inherited documentation)

wait_for_readability(self)

 
Stop current thread until the channel is readable.
Returns:
False if it won't be readable (e.g. is closed)
Overrides: mainloop.interfaces.IOHandler.wait_for_readability
(inherited documentation)

is_writable(self)

 
Returns:
True when the I/O channel can be written to
Overrides: mainloop.interfaces.IOHandler.is_writable
(inherited documentation)

wait_for_writability(self)

 
Stop current thread until the channel is writable.
Returns:
False if it won't be readable (e.g. is closed)
Overrides: mainloop.interfaces.IOHandler.wait_for_writability
(inherited documentation)

handle_write(self)

 
Handle the 'channel writable' state. E.g. send buffered data via a socket.
Overrides: mainloop.interfaces.IOHandler.handle_write
(inherited documentation)

handle_read(self)

 
Accept any incoming connections.
Overrides: mainloop.interfaces.IOHandler.handle_read

handle_hup(self)

 
Handle the 'channel hungup' state. The handler should not be writtable after this.
Overrides: mainloop.interfaces.IOHandler.handle_hup
(inherited documentation)

handle_err(self)

 
Handle an error reported.
Overrides: mainloop.interfaces.IOHandler.handle_err
(inherited documentation)

handle_nval(self)

 
Handle an 'invalid file descriptor' event.
Overrides: mainloop.interfaces.IOHandler.handle_nval
(inherited documentation)

Instance Variable Details [hide private]

_target

function to be called with accepted connection. It should expect two arguments: a connected socket and a socket address (as returned by accept)
Type:
callable