My idea is to new a socket event of scp listen socket, and in its event callback to do DIMSE command processing.
What I did is,
1. MyDcmSCP : DcmSCP
in MyDcmSCP,
2. a new member variable T_ASC_NETWORK *m_network added
3. overrided listen() : just return after ASC_initializeNetwork() is done, and have member variable m_network initialized instead of the local one like DcmSCP->listen()
4. a new member function getListenSock() is added to get socket on listening port.
Code: Select all
int MyDcmSCP ::getListenSock() {
if (m_network == NULL)
return -1;
else {
PRIVATE_NETWORKKEY ** networkKey = (PRIVATE_NETWORKKEY **) &(m_network->network);
return (*networkKey)->networkSpecific.TCP.listenSocket;
}
}
4. a new member function waitForAssociationRequest() added and it will be called when listen socket event is triggered, in it DcmSCP->waitForAssociationRQ() is called and with the m_network initialized in #3.
Code: Select all
OFCondition MyDcmSCP::waitForAssociationRequest()
{
if (m_network == NULL)
return ASC_NULLKEY;
OFCondition cond = EC_Normal;
cond = waitForAssociationRQ(m_network);
return cond;
}
And in the code, when MyDcmSCP->listen() is called, m_network is initialized, register a socket event which is obtained by getListenSock(). Then when a SCU request comes in , the event handler is fired to do the waitForAssociationRequest() . And now the problem is Association Abort thing always happens there. Was it the bad thing that m_network variable used like that? The reason to use it because I have no other way to pass the T_ASC_Netowrk to DcmSCP->waitForAssociationRQ().
Thanks for any guideline...
The SCP side,
[in:10/09/2013 15:31:06] Processing SOCKET (DICOM driver association listen/read) event 0x044A04A0
[in:10/09/2013 15:31:06] Calling cb 0x455a10
D: setting network send timeout to 60 seconds
D: setting network receive timeout to 60 seconds
T: DUL FSM Table: State: 1 Event: 4
T: DUL Event: Transport connection indication
T: DUL Action: AE 5 Transport Connect Response
T: Read PDU HEAD TCP: 01 00 00 00 00 cd
T: Read PDU HEAD TCP: type: 01, length: 205 (cd)
T: DUL FSM Table: State: 2 Event: 5
T: DUL Event: A-ASSOCIATE-RQ PDU (on transport)
T: DUL Action: AE 6 Examine Associate Request
D: PDU Type: Associate Request, PDU Length: 205 + 6 bytes PDU header
D: 01 00 00 00 00 cd 00 01 00 00 41 4e 59 2d 53 43
D: 50 20 20 20 20 20 20 20 20 20 45 43 48 4f 53 43
D: 55 20 20 20 20 20 20 20 20 20 00 00 00 00 00 00
D: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
D: 00 00 00 00 00 00 00 00 00 00 10 00 00 15 31 2e
D: 32 2e 38 34 30 2e 31 30 30 30 38 2e 33 2e 31 2e
D: 31 2e 31 20 00 00 2e 01 00 ff 00 30 00 00 11 31
D: 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 31 2e 31
D: 40 00 00 11 31 2e 32 2e 38 34 30 2e 31 30 30 30
D: 38 2e 31 2e 32 50 00 00 3a 51 00 00 04 00 00 40
D: 00 52 00 00 1b 31 2e 32 2e 32 37 36 2e 30 2e 37
D: 32 33 30 30 31 30 2e 33 2e 30 2e 33 2e 36 2e 30
D: 55 00 00 0f 4f 46 46 49 53 5f 44 43 4d 54 4b 5f
D: 33 36 30
D: Parsing an A-ASSOCIATE PDU
T: PDU type: 1 (A-ASSOCIATE RQ), PDU Length: 205
T: DICOM Protocol: 1
T: Called AP Title: ANY-SCP
T: Calling AP Title: ECHOSCU
T: Parsing remaining 137 bytes of A-ASSOCIATE PDU
T: Next item type: 10
T: Subitem parse: Type 10, Length 0021, Content: 1.2.840.10008.3.1.1.1
T: Successfully parsed Application Context
T: Parsing remaining 112 bytes of A-ASSOCIATE PDU
T: Next item type: 20
T: Parsing Presentation Context: (20), Length: 46
T: Presentation Context ID: 01
T: Parsing remaining 42 bytes of Presentation Context
T: Next item type: 30
T: Subitem parse: Type 30, Length 0017, Content: 1.2.840.10008.1.1
T: Successfully parsed Abstract Syntax
T: Parsing remaining 21 bytes of Presentation Context
T: Next item type: 40
T: Subitem parse: Type 40, Length 0017, Content: 1.2.840.10008.1.2
T: Successfully parsed Transfer Syntax
T: Successfully parsed Presentation Context
T: Parsing remaining 62 bytes of A-ASSOCIATE PDU
T: Next item type: 50
T: Parsing user info field (50), Length: 58
T: Parsing remaining 58 bytes of User Information
T: Next item type: 51
T: Maximum PDU Length: 16384
T: Successfully parsed Maximum PDU Length
T: Parsing remaining 50 bytes of User Information
T: Next item type: 52
T: Subitem parse: Type 52, Length 0027, Content: 1.2.276.0.7230010.3.0.3.6.0
T: Parsing remaining 19 bytes of User Information
T: Next item type: 55
T: Subitem parse: Type 55, Length 0015, Content: OFFIS_DCMTK_360
T: Successfully parsed User Information
I: Association Received localhost: ECHOSCU -> ANY-SCP
D: Incoming Association Request:
D: ====================== BEGIN A-ASSOCIATE-RQ =====================
D: Our Implementation Class UID: 1.2.276.0.7230010.3.0.3.6.1
D: Our Implementation Version Name: OFFIS_DCMTK_361
D: Their Implementation Class UID: 1.2.276.0.7230010.3.0.3.6.0
D: Their Implementation Version Name: OFFIS_DCMTK_360
D: Application Context Name: 1.2.840.10008.3.1.1.1
D: Calling Application Name: ECHOSCU
D: Called Application Name: ANY-SCP
D: Responding Application Name:
D: Our Max PDU Receive Size: 16384
D: Their Max PDU Receive Size: 16384
D: Presentation Contexts:
D: Context ID: 1 (Proposed)
D: Abstract Syntax: =VerificationSOPClass
D: Proposed SCP/SCU Role: Default
D: Proposed Transfer Syntax(es):
D: =LittleEndianImplicit
D: Requested Extended Negotiation: none
D: Accepted Extended Negotiation: none
D: Requested User Identity Negotiation: none
D: User Identity Negotiation Response: none
D: ======================= END A-ASSOCIATE-RQ ======================
T: DUL FSM Table: State: 3 Event: 6
T: DUL Event: A-ASSOCIATE resp prim (accept)
T: DUL Action: AE 7 Send Associate AC
D: Constructing Associate AC PDU
D: DcmSCP: Association Acknowledged
I: Association Acknowledged (Max Send PDV: 16372)
D: ====================== BEGIN A-ASSOCIATE-AC =====================
D: Our Implementation Class UID: 1.2.276.0.7230010.3.0.3.6.1
D: Our Implementation Version Name: OFFIS_DCMTK_361
D: Their Implementation Class UID: 1.2.276.0.7230010.3.0.3.6.0
D: Their Implementation Version Name: OFFIS_DCMTK_360
D: Application Context Name: 1.2.840.10008.3.1.1.1
D: Calling Application Name: ECHOSCU
D: Called Application Name: ANY-SCP
D: Responding Application Name: ANY-SCP
D: Our Max PDU Receive Size: 16384
D: Their Max PDU Receive Size: 16384
D: Presentation Contexts:
D: Context ID: 1 (Accepted)
D: Abstract Syntax: =VerificationSOPClass
D: Proposed SCP/SCU Role: Default
D: Accepted SCP/SCU Role: Default
D: Accepted Transfer Syntax: =LittleEndianImplicit
D: Requested Extended Negotiation: none
D: Accepted Extended Negotiation: none
D: Requested User Identity Negotiation: none
D: User Identity Negotiation Response: none
D: ======================= END A-ASSOCIATE-AC ======================
T: DIMSE receiveCommand
T: Read PDU HEAD TCP: 04 00 00 00 00 4a
T: Read PDU HEAD TCP: type: 04, length: 74 (4a)
T: DUL FSM Table: State: 6 Event: 9
T: DUL Event: P-DATA-TF PDU (on transport)
T: DUL Action: DT 2 Indicate P DATA PDU Received
D: DcmDataset::read() TransferSyntax="Little Endian Implicit"
T: DcmItem::readTagAndLength() TransferSyntax="Little Endian Implicit"
T: DcmItem::insert() Element (0000,0000) VR="UL" inserted at beginning
T: DcmItem::readSubItem() returns error = Normal
T: DcmItem::readTagAndLength() TransferSyntax="Little Endian Implicit"
T: DcmItem::insert() Element (0000,0002) VR="UI" inserted
T: DcmItem::readSubItem() returns error = Normal
T: DcmItem::readTagAndLength() TransferSyntax="Little Endian Implicit"
T: DcmItem::insert() Element (0000,0100) VR="US" inserted
T: DcmItem::readSubItem() returns error = Normal
T: DcmItem::readTagAndLength() TransferSyntax="Little Endian Implicit"
T: DcmItem::insert() Element (0000,0110) VR="US" inserted
T: DcmItem::readSubItem() returns error = Normal
T: DcmItem::readTagAndLength() TransferSyntax="Little Endian Implicit"
T: DcmItem::insert() Element (0000,0800) VR="US" inserted
T: DcmItem::readSubItem() returns error = Normal
T: DcmItem::readTagAndLength() TransferSyntax="Little Endian Implicit"
T: DcmItem::read() returns error = Normal
T: DcmDataset::read() returns error = Normal
T: DIMSE receiveCommand: 1 PDVs (68 bytes), PresID=1
T: DIMSE Command Received:
T:
T: # Dicom-Data-Set
T: # Used TransferSyntax: Little Endian Implicit
T: (0000,0002) UI =VerificationSOPClass # 18, 1 AffectedSOPClassUID
T: (0000,0100) US 48 # 2, 1 CommandField
T: (0000,0110) US 1 # 2, 1 MessageID
T: (0000,0800) US 257 # 2, 1 CommandDataSetType
T:
T: DcmItem::searchSubFromHere() Element (0000,0100) found
T: DcmItem::searchSubFromHere() Element (0000,0100) found
T: DcmItem::searchSubFromHere() Element (0000,0110) found
T: DcmItem::searchSubFromHere() Element (0000,0800) found
T: DcmItem::searchSubFromHere() Element (0000,0002) found
I: Received C-ECHO Request
D: ===================== INCOMING DIMSE MESSAGE ====================
D: Message Type : C-ECHO RQ
D: Presentation Context ID : 1
D: Message ID : 1
D: Data Set : none
D: ======================= END DIMSE MESSAGE =======================
I: Sending C-ECHO Response
T: DcmItem::insert() Element (0000,0000) VR="UL" inserted at beginning
T: DcmItem::insert() Element (0000,0100) VR="US" inserted
T: DcmItem::insert() Element (0000,0120) VR="US" inserted
T: DcmItem::insert() Element (0000,0800) VR="US" inserted
T: DcmItem::insert() Element (0000,0900) VR="US" inserted
T: DcmItem::insert() Element (0000,0002) VR="UI" inserted
T: DIMSE Command to be sent on Presentation Context ID: 1
T: DIMSE Command to send:
T:
T: # Dicom-Data-Set
T: # Used TransferSyntax: Little Endian Explicit
T: (0000,0000) UL 0 # 4, 1 CommandGroupLength
T: (0000,0002) UI =VerificationSOPClass # 18, 1 AffectedSOPClassUID
T: (0000,0100) US 32816 # 2, 1 CommandField
T: (0000,0120) US 1 # 2, 1 MessageIDBeingRespondedTo
T: (0000,0800) US 257 # 2, 1 CommandDataSetType
T: (0000,0900) US 0 # 2, 1 Status
T:
T: DIMSE sendDcmDataset: sending 78 bytes
T: DUL FSM Table: State: 6 Event: 8
T: DUL Event: P-DATA request primitive
T: DUL Action: DT 1 Send P DATA PDU
D: C-ECHO Response successfully sent
T: DIMSE receiveCommand
T: DUL FSM Table: State: 6 Event: 16
T: DUL Event: Transport connection closed
T: DUL Action: AA 4 Indicate AP Abort
I: Received Association Abort Request
D: DcmSCP: Association Terminated
D: +++++++++++++++++++++++++++++
The SCU side,
E:\dcmtk\dcmtk-3.6.0-win32-i386\bin>echoscu -v localhost 1112
I: Requesting Association
I: Association Accepted (Max Send PDV: 16372)
I: Sending Echo Request: MsgID 1
I: Received Echo Response (Status: Success)
I: Releasing Association
F: Association Release Failed: 0006:0317 Peer aborted Association (or never connected)