Module sketcher :: Class network
[hide private]
[frames] | no frames]

Class network

source code

This is the class for controlling the network communication between multiple online canvases inbounded on the current machine, or outbounded to multiple remote machines. The primary goal of this class is to establish and maintain multiple connections by spawning a single server process thread/daemon which waits for incoming/inbounding connections and acknowledging them upon the user's grant; and to make outgoing/outbounding requests to a remote system based on the user's request. The application may be in several states at a time: it may act as a server without having a session with another machine; it may may be a server without an inbound connection, but an established outbounded connection with one or more remote machines; it may be a server with inbounded connections, but no outbounded connections; or it may be both connected inboundly and outboundly.

Instance Methods [hide private]
 
__init__(this)
Initializes the network, by creating a new server daemon process.
source code
 
client(this, host, port=1832)
Connects to a remote host machine, given it's ip and, optionally, it's port number.
source code
 
server(this, port)
Starts-up the server on the current machine, by binding a sever daeom process to the a ip address, and port number.
source code
 
serverthrd(this)
Server thread used to act independently of the current user processes.
source code
 
send(this, event)
Sends an event to a remote machine.
source code
 
receive(this, c)
A server thread immediately jumps into receving mode, where in the lifetime of its connection with the remote client machine, it receives and queues each event that is transmitted.
source code
Method Details [hide private]

server(this, port)

source code 

Starts-up the server on the current machine, by binding a sever daeom process to the a ip address, and port number. Parameter:

  • port, the port number to bound the server process.

serverthrd(this)

source code 

Server thread used to act independently of the current user processes. Each thread is dedicated to a single connecting remote client machine - the events passed from that machine are pushed to the current hosting machine.

send(this, event)

source code 

Sends an event to a remote machine. The respective machines will then push this event to their event stack to to be handled has if the current sending machine is directly interacting with the remote machine. Parameter:

  • event, the event object to be transmitted to a remote client.

receive(this, c)

source code 

A server thread immediately jumps into receving mode, where in the lifetime of its connection with the remote client machine, it receives and queues each event that is transmitted. Parameter:

  • c, the (socket, address) pair of the client machine to receive events from.