DUL Service Provider

This module implements the DUL service provider, allowing a DUL service user to send and receive DUL messages (PDUs). The User and Provider talk to each other using a TCP socket. The DULServer runs in a thread, polling TCP socket for incoming messages and sending messages from user queue. Underlying logic of the service is implemented via state machine that is described in DICOM standard.

In most of the cases you would not need to access DULServiceProvider directly, but rather would use higher level objects like sub-classes of Association or various services.

class netdicom2.dulprovider.DULServiceProvider(dul_socket=None)

Implements DUL service.

This class is responsible for low-level operations with incoming and outgoing PDUs.

Service can be initialized by providing open socket that service would use for sending and receiving PDUs. In case if socket is not provider service opens a client socket by itself when sending AAssociateRqPDU instance.

Underlying implementation relies on state machine that is defined in Service State Machine

send(primitive)

Puts PDU into outgoing queue.

Note

PDU is not immediately written into the socket, but rather put into queue that is processed by service event loop.

Parameters:primitive – outgoing PDU. Possible PDU types are described in PDU Types
receive(timeout)

Tries to get PDU from incoming queue.

If timeout is exceeded method rises TimeoutError exception.

Parameters:timeout – the amount of seconds method waits for PDU to appear in incoming queue
Returns:PDU instance. Possible PDU types are described in PDU Types
Raises:exceptions.TimeoutError – If specified timeout is exceeded
stop()

Tries to stop service for idle association.

If association is not in idle state, method will return False and association will not be stopped.

Returns:True if service termination flag was successfully set (current association state was ‘idle’), False otherwise
kill()

Sets termination flag for event loop and waits for thread to exit.

run()

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.