Connections

class secsgem.hsms.connections.HsmsConnection(active, address, port, session_id=0, delegate=None)[source]

Bases: object

Connection class used for active and passive hsms connections.

Parameters:
  • active (boolean) – Is the connection active (True) or passive (False)
  • address (string) – IP address of remote host
  • port (integer) – TCP port of remote host
  • session_id (integer) – session / device ID to use for connection
  • delegate (inherited from secsgem.hsms.handler.HsmsHandler) – target for messages
selectTimeout = 0.5

Timeout for select calls

sendBlockSize = 1048576

Block size for outbound data

T3 = 45.0

Reply Timeout

T5 = 10.0

Connect Separation Time

T6 = 5.0

Control Transaction Timeout

disconnect()[source]

Close connection

send_packet(packet)[source]

Send the ASCII coded packet to the remote host

Parameters:packet (string / byte array) – encoded data to be transmitted
class secsgem.hsms.connections.HsmsActiveConnection(address, port=5000, session_id=0, delegate=None)[source]

Bases: secsgem.hsms.connections.HsmsConnection

Client class for single active (outgoing) connection

Parameters:
  • address (string) – IP address of target host
  • port (integer) – TCP port of target host
  • session_id (integer) – session / device ID to use for connection
  • delegate (object) – target for messages

Example:

# TODO: create example
T3 = 45.0
T5 = 10.0
T6 = 5.0
disconnect()

Close connection

selectTimeout = 0.5
sendBlockSize = 1048576
send_packet(packet)

Send the ASCII coded packet to the remote host

Parameters:packet (string / byte array) – encoded data to be transmitted
enable()[source]

Enable the connection.

Starts the connection process to the passive remote.

disable()[source]

Disable the connection.

Stops all connection attempts, and closes the connection

class secsgem.hsms.connections.HsmsPassiveConnection(address, port=5000, session_id=0, delegate=None)[source]

Bases: secsgem.hsms.connections.HsmsConnection

Server class for single passive (incoming) connection

Creates a listening socket and waits for one incoming connection on this socket. After the connection is established the listening socket is closed.

Parameters:
  • address (string) – IP address of target host
  • port (integer) – TCP port of target host
  • session_id (integer) – session / device ID to use for connection
  • delegate (object) – target for messages

Example:

# TODO: create example
enable()[source]

Enable the connection.

Starts the connection process to the passive remote.

disable()[source]

Disable the connection.

Stops all connection attempts, and closes the connection

T3 = 45.0
T5 = 10.0
T6 = 5.0
disconnect()

Close connection

selectTimeout = 0.5
sendBlockSize = 1048576
send_packet(packet)

Send the ASCII coded packet to the remote host

Parameters:packet (string / byte array) – encoded data to be transmitted
class secsgem.hsms.connections.HsmsMultiPassiveConnection(address, port=5000, session_id=0, delegate=None)[source]

Bases: secsgem.hsms.connections.HsmsConnection

Connection class for single connection from secsgem.hsms.connections.HsmsMultiPassiveServer

Handles connections incoming connection from secsgem.hsms.connections.HsmsMultiPassiveServer

Parameters:
  • address (string) – IP address of target host
  • port (integer) – TCP port of target host
  • session_id (integer) – session / device ID to use for connection
  • delegate (object) – target for messages

Example:

# TODO: create example
on_connected(sock, address)[source]

Connected callback for secsgem.hsms.connections.HsmsMultiPassiveServer

Parameters:
  • sock (Socket) – Socket for new connection
  • address (string) – IP address of remote host
enable()[source]

Enable the connection.

Starts the connection process to the passive remote.

disable()[source]

Disable the connection.

Stops all connection attempts, and closes the connection

T3 = 45.0
T5 = 10.0
T6 = 5.0
disconnect()

Close connection

selectTimeout = 0.5
sendBlockSize = 1048576
send_packet(packet)

Send the ASCII coded packet to the remote host

Parameters:packet (string / byte array) – encoded data to be transmitted
class secsgem.hsms.connections.HsmsMultiPassiveServer(port=5000)[source]

Bases: object

Server class for multiple passive (incoming) connection. The server creates a listening socket and waits for incoming connections on this socket.

Parameters:port (integer) – TCP port to listen on

Example:

# TODO: create example
selectTimeout = 0.5

Timeout for select calls

create_connection(address, port=5000, session_id=0, delegate=None)[source]

Create and remember connection for the server

Parameters:
  • address (string) – IP address of target host
  • port (integer) – TCP port of target host
  • session_id (integer) – session / device ID to use for connection
  • delegate (object) – target for messages
start()[source]

Starts the server and returns. It will launch a listener running in background to wait for incoming connections.

stop(terminate_connections=True)[source]

Stops the server. The background job waiting for incoming connections will be terminated. Optionally all connections received will be closed.

Parameters:terminate_connections (boolean) – terminate all connection made by this server