Package xmpp :: Module transports :: Class TCPsocket
[hide private]
[frames] | no frames]

Class TCPsocket

source code


This class defines direct TCP connection method.

Instance Methods [hide private]
 
__init__(self, server=None, use_srv=True)
Cache connection point 'server'.
source code
 
srv_lookup(self, server)
SRV resolver.
source code
 
plugin(self, owner)
Fire up connection.
source code
 
getHost(self)
Return the 'host' value that is connection is [will be] made to.
source code
 
getPort(self)
Return the 'port' value that is connection is [will be] made to.
source code
 
connect(self, server=None)
Try to connect to the given host/port.
source code
 
plugout(self)
Disconnect from the remote server and unregister self.disconnected method from the owner's dispatcher.
source code
 
receive(self)
Reads all pending incoming data.
source code
 
send(self, raw_data, retry_timeout=1)
Writes raw outgoing data.
source code
 
pending_data(self, timeout=0)
Returns true if there is a data ready to be read.
source code
 
disconnect(self)
Closes the socket.
source code
 
disconnected(self)
Called when a Network Error or disconnection occurs.
source code

Inherited from client.PlugIn: DEBUG, PlugIn, PlugOut

Method Details [hide private]

__init__(self, server=None, use_srv=True)
(Constructor)

source code 

Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. However library will lookup for ('_xmpp-client._tcp.' + host) SRV record in DNS and connect to the found (if it is) server instead

Overrides: client.PlugIn.__init__

srv_lookup(self, server)

source code 

SRV resolver. Takes server=(host, port) as argument. Returns new (host, port) pair

plugin(self, owner)

source code 

Fire up connection. Return non-empty string on success. Also registers self.disconnected method in the owner's dispatcher. Called internally.

connect(self, server=None)

source code 

Try to connect to the given host/port. Does not lookup for SRV record. Returns non-empty string on success.

receive(self)

source code 

Reads all pending incoming data. In case of disconnection calls owner's disconnected() method and then raises IOError exception.

send(self, raw_data, retry_timeout=1)

source code 

Writes raw outgoing data. Blocks until done. If supplied data is unicode string, encodes it to utf-8 before send.

disconnected(self)

source code 

Called when a Network Error or disconnection occurs. Designed to be overidden.