Package i2p :: Module tunnel :: Class Tunnel
[show private | hide private]
[frames | no frames]

Class Tunnel

Known Subclasses:
TunnelClient, TunnelServer

Method Summary
  __init__(self, receive, make_send, nconnect, timeout)
A Tunnel relays connections from a 'receive' socket to one or more 'send' sockets.
  close(self)
Close all connections made for this tunnel.
  _run(self)
Manage the tunnel in a separate thread.

Method Details

__init__(self, receive, make_send, nconnect=-1, timeout=60.0)
(Constructor)

A Tunnel relays connections from a 'receive' socket to one or more 'send' sockets. The receive socket must be bound and listening. For each incoming connection, a new send socket is created by calling make_send(). Data is then exchanged between the created streams until one socket is closed. nconnect is the maximum number of simultaneous connections (-1 for infinite), and timeout is the time that a single connection can last for (None allows a connection to last forever).

Sockets must accept stream traffic and support the Python socket interface. A separate daemonic thread is created to manage the tunnel. For high performance, make_send() should make a socket and connect in non-blocking mode (you should catch and discard the socket.BlockError or socket.error due to executing connect on a non-blocking socket).

Security Note: A firewall is needed to maintain the end user's anonymity. An attacker could keep a tunnel socket open by pinging it regularly. The accepted sockets from 'receive' must prevent this by closing down eventually.

Socket errors do not cause the Tunnel to shut down.

close(self)

Close all connections made for this tunnel.

_run(self)

Manage the tunnel in a separate thread.

Generated by Epydoc 2.1 on Mon Aug 02 01:07:41 2004 http://epydoc.sf.net