Package CyberRail :: Package common :: Module communicationmanager :: Class ConnectionHandle
[hide private]
[frames] | no frames]

Class ConnectionHandle

source code


The Connection Handle contains the IO buffers of the associated socket. For inputs, it stores all data until a complete protocol packet is receive For outputs, it stores all data until the socket is ready to send.

This class in only needed for the default communication manager, the Qt ones has it's own mechanism.

Operations on buffers run as FIFO.

Instance Methods [hide private]
 
__init__(self, cm, socket, protoIn=None, protoOut=None, ssl=False)
Create a new Connection Handle.
source code
 
getOutData(self)
Returns: a copy of all data in the out buffer.
source code
 
removeOutData(self, howMany)
Clear part of the out buffer.
source code
 
addOutData(self, data)
Add some data at the end of the out buffer.
source code
 
getInData(self)
Get input data.
source code
 
clearInData(self, howMany=None)
Clear input buffer.
source code
 
addInData(self, data)
Add data which has just be read.
source code
 
sid(self)
Returns: the socket id.
source code
 
enableSSL(self, serverSide)
Enable the ssl wrapper around this socket
source code
 
disableSSL(self)
Disable the ssl wrapper.
source code

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

Class Variables [hide private]
  GARBAGE = 0
Stream is corrupted or doesn't contain any valid data.
  OK = 1
Stream format is ok
  UNDEFINED = 2
Stream format is ok, but nothing has to be reported
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, cm, socket, protoIn=None, protoOut=None, ssl=False)
(Constructor)

source code 

Create a new Connection Handle. The specific protocol callback will be used instead of the CommunicationManager ones if they are set.

Parameters:
  • cm - an instance of a CommunicationManager
  • socket - the associated socket
  • protoIn - specific protocol callback (see CommunicationManager.__init__ doc)
  • protoOut - specific protocol callback (see CommunicationManager.__init__ doc)
  • ssl - enable ssl if True
Overrides: object.__init__

getOutData(self)

source code 
Returns:
a copy of all data in the out buffer. Data has not been sent and is not cleared at the end of the call.

Thread-safe.

removeOutData(self, howMany)

source code 

Clear part of the out buffer. If no more data is present, the pollout flag is removed.

Thread-safe.

Parameters:
  • howMany - how many bytes to remove from the beginning of the buffer

addOutData(self, data)

source code 

Add some data at the end of the out buffer. The pollout flag is set. If the socket is ready, data is immediatly sent at the next loop turn.

Thread-safe

Parameters:
  • data - a string of bytes
Returns:
the number of bytes in the buffer

getInData(self)

source code 

Get input data. Data stays in the buffer.

clearInData(self, howMany=None)

source code 

Clear input buffer. Used by protoIn callback.

Parameters:
  • howMany - How many bytes to remove. Default to None which means all data.

addInData(self, data)

source code 

Add data which has just be read. Only used by CommunicationManager.

sid(self)

source code 
Returns:
the socket id.

Note: this is the file descriptor.

enableSSL(self, serverSide)

source code 

Enable the ssl wrapper around this socket

Parameters:
  • serverMode - True is this socket is a server socket

Class Variable Details [hide private]

GARBAGE

Stream is corrupted or doesn't contain any valid data. The stream will be flushed by the system

Value:
0