pynetdicom.transport.AssociationSocket#
- class pynetdicom.transport.AssociationSocket(assoc: Association, client_socket: socket | None = None, address: AddressInformation | None = None)[source]#
A wrapper for a socket object.
Provides an interface for
socketthat is integrated nicely with anAssociationinstance and the state machine.Changed in version 3.0: Added support for IPv6 addresses.
- select_timeout#
The timeout (in seconds) that
select.select()calls inready()will block for (default0.5). A value of0specifies a poll and never blocks. A value ofNoneblocks until a connection is ready.- Type:
float or None
- socket#
The wrapped socket, will be
Noneifclose()is called.- Type:
socket.socket or None
- __init__(assoc: Association, client_socket: socket | None = None, address: AddressInformation | None = None) None[source]#
Create a new
AssociationSocket.Changed in version 3.0: address now takes an
AddressInformationinstance.- Parameters:
assoc (association.Association) – The
Associationinstance that will be using the socket to communicate.client_socket (socket.socket, optional) – Required if address is
None, thesocket.socketto wrap.address (pynetdicom.transport.AddressInformation, optional) – Required if client_socket is
Nonethen create a new socket and bind it to this address.
Methods
__init__(assoc[, client_socket, address])Create a new
AssociationSocket.close()Close the connection to the peer and shutdown the socket.
connect(primitive)Try and connect to a remote using connection details from primitive.
get_local_addr([host])Return an address for the local computer as
str.recv(nr_bytes)Read nr_bytes from the socket.
send(bytestream)Try and send the data in bytestream to the remote.
Attributes
Return the parent
Associationinstance.Return the
Association's service event queue.Return the
Association's service provider queue.Return
Trueif there is data available to be read.Get or set the TLS context and hostname.
- property assoc: Association#
Return the parent
Associationinstance.
- close() None[source]#
Close the connection to the peer and shutdown the socket.
Sets
AssociationSocket.sockettoNoneonce complete.Events Emitted
Evt17: Transport connection closed
- connect(primitive: T_CONNECT) None[source]#
Try and connect to a remote using connection details from primitive.
Changed in version 2.0: Changed to take a
T_CONNECTprimitive rather than an address tuple.- Parameters:
primitive (pynetdicom.transport.T_CONNECT) – The TRANSPORT CONNECT primitive to use when connecting to a peer.
- property event_queue: Queue[str]#
Return the
Association’s service event queue.
- get_local_addr(host: tuple[str, int] = ('10.255.255.255', 1)) str[source]#
Return an address for the local computer as
str.Deprecated since version 3.0: This method will be removed in v4.0.
- property provider_queue: _QueueType#
Return the
Association’s service provider queue.
- property ready: bool#
Return
Trueif there is data available to be read.Events Emitted
None
Evt17: Transport connection closed
- Returns:
Trueif the socket has data ready to be read,Falseotherwise.- Return type:
- send(bytestream: bytes) None[source]#
Try and send the data in bytestream to the remote.
Events Emitted
None
Evt17: Transport connected closed.
- Parameters:
bytestream (bytes) – The data to send to the remote.
- property tls_args: tuple[ssl.SSLContext, str] | None#
Get or set the TLS context and hostname.
- Parameters:
tls_args (tuple[ssl.SSLContext, str] or None) – If the socket should be wrapped by TLS then this is
(context, hostname), where context is assl.SSLContextthat will be used to wrap the socket and hostname is the value to use for the server_hostname keyword argument forSSLContext.wrap_socket().- Return type:
tuple[ssl.SSLContext, str] | None