pynetdicom.transport.AssociationSocket¶
-
class
pynetdicom.transport.AssociationSocket(assoc, client_socket=None, address=('', 0))[source][source]¶ A wrapper for the socket.socket object.
Provides an interface for socket.socket that is integrated nicely with a pynetdicom Association instance and the state machine.
-
select_timeout¶ The timeout (in seconds) that select.select() calls in
readywill block for (default 0.5). A value of 0 specifies a poll and never blocks. A value of None blocks until a connection is ready.Type: float or None
-
socket¶ The wrapped socket, will be None if AssociationSocket.close() is called.
Type: socket.socket or None
-
tls_args¶ If the socket should be wrapped by TLS then this is (context, hostname), where context is a ssl.SSLContext that will be used to wrap the socket and hostname is the value to use for the server_hostname keyword argument for
SSLContext.wrap_socket()If TLS is not to be used then None (default).Type: 2-tuple or None
-
__init__(assoc, client_socket=None, address=('', 0))[source][source]¶ Create a new AssociationSocket.
Parameters: - assoc (association.Association) – The Association instance that will be using the socket to communicate.
- client_socket (socket.socket, optional) – The socket to wrap, if not supplied then a new socket will be created instead.
- address (2-tuple) – If client_socket is None then this is the (host, port) to bind the newly created socket to, which by default will be (‘’, 0).
Methods
__init__(assoc[, client_socket, address])Create a new AssociationSocket. close()Close the connection to the peer and shutdown the socket. connect(address)Try and connect to a remote. recv(nr_bytes)Read nr_bytes from the socket. send(bytestream)Try and send bystream to the remote. Attributes
assocReturn the socket’s parent Association instance. event_queueReturn the Association’s event queue. readyReturn True if there is data available to be read. -
assoc¶ Return the socket’s parent Association instance.
-
close()[source][source]¶ Close the connection to the peer and shutdown the socket.
Sets
AssociationSocket.sockettoNoneonce complete.Events Emitted
- Evt17: Transport connection closed
-
connect(address)[source][source]¶ Try and connect to a remote.
Events Emitted
- Evt2: Transport connection confirmed
- Evt17: Transport connection closed
Parameters: address (2-tuple) – The (host, port) IPv4 address to connect to.
-
event_queue¶ Return the Association’s event queue.
-
ready¶ Return True if there is data available to be read.
Events Emitted
- None
- Evt17: Transport connection closed
Returns: True if the socket has data ready to be read, False otherwise. Return type: bool
-