Package com.pixelmed.network
Class Association
java.lang.Object
com.pixelmed.network.Association
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected String
protected String
protected InputStream
protected String
protected int
protected OutputStream
protected LinkedList
protected String
protected LinkedList
protected Socket
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Send an A-ABORT-RQ.int
getAssociationOutputStream
(byte presentationContextID) A factory method to build anAssociationOutputStream
for this Association, on which to send data which is fragmented as appropriate into PDUs.abstract String
abstract int
abstract String
abstract int
protected String
protected int
protected String
protected int
protected static byte[]
getRestOfPDU
(InputStream in, byte[] startBuffer, int pduLength) byte
getSuitablePresentationContextID
(String abstractSyntaxUID) Find a Presentation Context for the a particular SOP Class UID, using any available Transfer Syntax but preferring compressed then, Explicit VR Little Endian, then any Explicit VR, over Implicit VR.byte
getSuitablePresentationContextID
(String abstractSyntaxUID, String transferSyntaxUID) Find a Presentation Context for a particular combination of SOP Class UID and Transfer Syntax.getTransferSyntaxForPresentationContextID
(byte identifier) Get the Transfer Syntax UID of the Presentation Context specified by the Presentation Context ID.protected static void
readInsistently
(InputStream in, byte[] b, int offset, int length, String what) void
release()
Send an A-RELEASE-RQ.void
send
(byte presentationContextID, byte[] command, byte[] data) Send a command and/or data in a single PDU, each PDV with the last fragment flag set.void
Register aReceivedDataHandler
to handle each PDU as it is received.protected void
setSocketOptions
(Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize) Set the socket options for either initiator or acceptor.protected void
setSocketOptions
(Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, int debugLevel) Set the socket options for either initiator or acceptor.toString()
void
Continue to transfer data (remain in State 6) until the last fragment of a command has been received.void
Continue to transfer data (remain in State 6) until the last fragment of data has been received.void
Continue to transfer data (remain in State 6) until one PDU has been received.void
waitForPDataPDUs
(int count, boolean stopAfterLastFragmentOfCommand, boolean stopAfterLastFragmentOfData, boolean stopAfterHandlerReportsDone) Continue to transfer data (remain in State 6) until the specified number of PDUs have been received or the specified conditions are satisfied.void
Continue to transfer data (remain in State 6) until the data handler reports that it is done.
-
Field Details
-
associationNumber
protected int associationNumber -
calledAETitle
-
callingAETitle
-
presentationContexts
-
scuSCPRoleSelections
-
maximumLengthReceived
protected int maximumLengthReceived -
socket
-
in
-
out
-
remoteHostName
-
localHostName
-
-
Constructor Details
-
Association
protected Association() -
Association
protected Association(int debugLevel) - Parameters:
debugLevel
- ignored
-
-
Method Details
-
setSocketOptions
protected void setSocketOptions(Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, int debugLevel) throws IOException Set the socket options for either initiator or acceptor.
Must be called before using the socket or the options won't set.
- Parameters:
socket
- the socket whose options to setourMaximumLengthReceived
- the maximum PDU length that we will offer to receivesocketReceiveBufferSize
- the TCP socket receive buffer size to set (if possible), 0 means leave at the defaultsocketSendBufferSize
- the TCP socket send buffer size to set (if possible), 0 means leave at the defaultdebugLevel
- ignored- Throws:
IOException
-
setSocketOptions
protected void setSocketOptions(Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize) throws IOException Set the socket options for either initiator or acceptor.
Must be called before using the socket or the options won't set.
- Parameters:
socket
- the socket whose options to setourMaximumLengthReceived
- the maximum PDU length that we will offer to receivesocketReceiveBufferSize
- the TCP socket receive buffer size to set (if possible), 0 means leave at the defaultsocketSendBufferSize
- the TCP socket send buffer size to set (if possible), 0 means leave at the default- Throws:
IOException
-
readInsistently
protected static void readInsistently(InputStream in, byte[] b, int offset, int length, String what) throws DicomNetworkException, IOException - Parameters:
in
-b
-offset
-length
-what
-- Throws:
IOException
DicomNetworkException
-
getRestOfPDU
protected static byte[] getRestOfPDU(InputStream in, byte[] startBuffer, int pduLength) throws DicomNetworkException, IOException - Parameters:
in
-startBuffer
-pduLength
-- Throws:
IOException
DicomNetworkException
-
release
Send an A-RELEASE-RQ. This is a confirmed service, so a normal return is the A-RELEASE confirmation primitive.- Throws:
DicomNetworkException
-
abort
Send an A-ABORT-RQ. This is an unconfirmed service, so a normal return is expected.- Throws:
DicomNetworkException
-
send
public void send(byte presentationContextID, byte[] command, byte[] data) throws DicomNetworkException Send a command and/or data in a single PDU, each PDV with the last fragment flag set.- Parameters:
presentationContextID
- included in the header of each PDUcommand
- the command PDV payload, or null if nonedata
- the data PDV payload, or null if none- Throws:
DicomNetworkException
-
getAssociationOutputStream
public AssociationOutputStream getAssociationOutputStream(byte presentationContextID) throws DicomNetworkException A factory method to build anAssociationOutputStream
for this Association, on which to send data which is fragmented as appropriate into PDUs.- Parameters:
presentationContextID
- included in the header of each PDU- Throws:
DicomNetworkException
-
setReceivedDataHandler
Register aReceivedDataHandler
to handle each PDU as it is received.- Parameters:
h
- an implementation of the abstract classReceivedDataHandler
- Throws:
DicomNetworkException
-
waitForPDataPDUs
public void waitForPDataPDUs(int count, boolean stopAfterLastFragmentOfCommand, boolean stopAfterLastFragmentOfData, boolean stopAfterHandlerReportsDone) throws DicomNetworkException, AReleaseException Continue to transfer data (remain in State 6) until the specified number of PDUs have been received or the specified conditions are satisfied. The registered receivedDataHandler is sent a PDataIndication.- Parameters:
count
- the number of PDUs to be transferred, or -1 if no limit (stop only when conditions satisfied)stopAfterLastFragmentOfCommand
- stop after the last fragment of a command has been receivedstopAfterLastFragmentOfData
- stop after the last fragment of data has been receivedstopAfterHandlerReportsDone
- stop after data handler reports that it is done- Throws:
DicomNetworkException
- A-ABORT or A-P-ABORT indicationAReleaseException
- A-RELEASE indication; transport connection is closed
-
waitForOnePDataPDU
Continue to transfer data (remain in State 6) until one PDU has been received. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException
- A-ABORT or A-P-ABORT indicationAReleaseException
- A-RELEASE indication; transport connection is closed
-
waitForCommandPDataPDUs
Continue to transfer data (remain in State 6) until the last fragment of a command has been received. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException
- A-ABORT or A-P-ABORT indicationAReleaseException
- A-RELEASE indication; transport connection is closed
-
waitForDataPDataPDUs
Continue to transfer data (remain in State 6) until the last fragment of data has been received. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException
- A-ABORT or A-P-ABORT indicationAReleaseException
- A-RELEASE indication; transport connection is closed
-
waitForPDataPDUsUntilHandlerReportsDone
public void waitForPDataPDUsUntilHandlerReportsDone() throws DicomNetworkException, AReleaseExceptionContinue to transfer data (remain in State 6) until the data handler reports that it is done. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException
- A-ABORT or A-P-ABORT indicationAReleaseException
- A-RELEASE indication; transport connection is closed
-
getSuitablePresentationContextID
Find a Presentation Context for the a particular SOP Class UID, using any available Transfer Syntax but preferring compressed then, Explicit VR Little Endian, then any Explicit VR, over Implicit VR.- Parameters:
abstractSyntaxUID
- the SOP Class UID for which to find a suitable Presentation Context- Returns:
- the Presentation Context ID of a suitable Presentation Context
- Throws:
DicomNetworkException
- thrown if no suitable Presentation Context
-
getSuitablePresentationContextID
public byte getSuitablePresentationContextID(String abstractSyntaxUID, String transferSyntaxUID) throws DicomNetworkException Find a Presentation Context for a particular combination of SOP Class UID and Transfer Syntax.- Parameters:
abstractSyntaxUID
- the SOP Class UID for which to find a suitable Presentation ContexttransferSyntaxUID
- the Transfer Syntax UID for which to find a suitable Presentation Context- Returns:
- the Presentation Context ID of a suitable Presentation Context
- Throws:
DicomNetworkException
- thrown if no suitable Presentation Context
-
getTransferSyntaxForPresentationContextID
public String getTransferSyntaxForPresentationContextID(byte identifier) throws DicomNetworkException Get the Transfer Syntax UID of the Presentation Context specified by the Presentation Context ID.- Parameters:
identifier
- the Presentation Context ID- Returns:
- the only or first Transfer Syntax UID
- Throws:
DicomNetworkException
- thrown if no such Presentation Context or no Transfer Syntax for that Presentation Context (e.g. it was rejected)
-
getAssociationNumber
public int getAssociationNumber() -
getCalledAETitle
-
getCallingAETitle
-
toString
-
getEndpointDescription
-
getRemoteHostName
-
getLocalHostName
-
getCallingAEHostName
-
getCalledAEHostName
-
getRemotePort
protected int getRemotePort() -
getLocalPort
protected int getLocalPort() -
getCallingAEPort
public abstract int getCallingAEPort() -
getCalledAEPort
public abstract int getCalledAEPort()
-