LDicomNet::IsISCLQueueEmpty

#include "ltdic.h"

L_BOOL LDicomNet::IsISCLQueueEmpty()

Determines whether the ISCL transmission queue is empty. This function is available in the PACS Imaging toolkits.

Returns

A value that indicates whether the ISCL transmission queue is empty. Possible values are:

Value Meaning
TRUE The ISCL transmission queue is empty.
FALSE The ISCL transmission queue is not empty.

Comments

The ISCL messages are added to the ISCL transmission queue, and will be sent in order on the network. Every object has its own ISCL transmission queue.

The ISCL transmission queue contains requests to send data, to send non-secure data and the requests for closing the connection. Closing the connection does not start until all send requests are processed.

Required DLLs and Libraries

Platforms

Win32, x64

See Also

Functions

Topics

Example

namespace LDicomNet_IsISCLQueueEmpty_Namespace 
{ 
   // Logs a message 
   // This implementation logs to the console, and the debug window 
   L_VOID LogMessage(TCHAR *szMsg) 
   { 
      wprintf(TEXT("\n")); 
      wprintf(szMsg); 
 
      OutputDebugStringW(TEXT("\n")); 
      OutputDebugStringW(szMsg); 
   } 
 
#define SERVER_AUTH_DATA       TEXT("LEAD server ISCL") 
#define SERVER_AUTH_DATA_LEN   17 
   L_VOID SetupISCL(LDicomNet *pNet) 
   { 
      pNet->SetMutualAuthAlgISCL(DICOM_ISCL_MUTUAL_AUTH_3P4W); 
      pNet->SetMutualAuthKeyISCL(1, 11619789628100321); 
      pNet->SetMutualAuthKeyISCL(2, 34217865672122111); 
      pNet->SetMutualAuthKeyISCL(3, 1605935625518899689); 
      pNet->SetMutualAuthKeyISCL(4, 138217077775855676); 
      pNet->SetMutualAuthKeyISCL(5, 9117318694593010212); 
      pNet->SetMutualAuthKeyISCL(6, 3485297985488245687); 
      pNet->SetMutualAuthKeyISCL(7, 1533287511573403981); 
      pNet->SetMutualAuthKeyISCL(8, 5604839976916070822); 
      pNet->SetIndexForMutualAuthISCL(1); 
 
      pNet->SetDefaultEncryptionISCL(DICOM_ISCL_ENCRYPT_DESCBC); 
      pNet->SetDefaultSigningISCL(DICOM_ISCL_MAC_MD5); 
      pNet->SetEncryptKeyISCL(1, 8079278526052745737); 
      pNet->SetEncryptKeyISCL(2, 1312864321990916052); 
      pNet->SetEncryptKeyISCL(3, 7190959962252002117); 
      pNet->SetEncryptKeyISCL(4, 3619524191167482890); 
      pNet->SetEncryptKeyISCL(5, 3466658849848898336); 
      pNet->SetEncryptKeyISCL(6, 8474124475946342520); 
      pNet->SetEncryptKeyISCL(7, 7725464453540259890); 
      pNet->SetEncryptKeyISCL(8, 4320705344832296668); 
      pNet->SetIndexForEncryptISCL(1); 
 
      pNet->SetMaxMessageLengthISCL(1024000); 
      pNet->SetMaxCommBlockLengthISCL(8129); 
      pNet->SetAuthDataISCL(SERVER_AUTH_DATA, SERVER_AUTH_DATA_LEN); 
   } 
 
   // ******************************************************************************************* 
   // Client Class  
   // 
   // Class that is used to connect to the server  
   // ******************************************************************************************* 
   class CMyClient : public LDicomNet 
   { 
   public: 
      CMyClient(L_INT32 nMode): LDicomNet(NULL, nMode) 
      { 
         m_waitEvent = CreateEvent( NULL, TRUE, TRUE, TEXT("ClientEvent")); 
         ResetEvent(m_waitEvent); 
      } 
 
      ~CMyClient(void) 
      { 
         CloseHandle(m_waitEvent); 
      } 
 
      // Client 
      L_VOID OnConnect                    (L_INT nError); 
      L_VOID OnSecureLinkReady            (L_UINT32 nError); 
      L_VOID OnReceiveAssociateAccept     (LDicomAssociate *pPDU); 
      L_VOID OnReceiveReleaseResponse     (); 
      L_VOID OnReceiveCEchoResponse       (L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus); 
 
      // ISCL Security Events 
      L_UINT32 GetChallengeISCL(L_UINT64 *pChallenge, L_UINT64 nParameter); 
      L_UINT32 InternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 *pResponse, L_UINT64 nParameter); 
      L_UINT32 ExternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 nResponse, L_UINT64 nParameter); 
 
      L_BOOL Wait(DWORD timeout = 5000); 
 
   private: 
      HANDLE m_waitEvent; 
   }; 
 
   // Continues dispatching messages until hEvent is signalled, our timeout 
   // Returns TRUE if hEvent is signalled 
   // Returns FALSE if timeout 
   L_BOOL MessageLoop ( 
      HANDLE hEvent, // handles that need to be waited on 
      DWORD timeout  // timeout in milliseconds 
      ) 
   { 
      DWORD dwStart = GetTickCount(); 
      MSG msg = {0}; 
      while (TRUE) 
      { 
         if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))  
         { 
            TranslateMessage(&msg); 
            DispatchMessage(&msg); 
         } 
 
         if (WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0) 
         { 
            ResetEvent(hEvent); 
            return TRUE; 
         } 
 
         DWORD dwCurrent = GetTickCount(); 
         if ((dwCurrent - dwStart) > timeout) 
         { 
            return FALSE; 
         } 
      } 
   } 
 
   L_VOID CMyClient::OnConnect(L_INT nError) 
   { 
      L_TCHAR szMsg[200] = {0}; 
 
      wsprintf(szMsg, TEXT("CMyClient::OnConnect: nError[%d]"), nError);  
      LogMessage(szMsg); 
   } 
 
   L_VOID CMyClient::OnSecureLinkReady(L_UINT32 nError) 
   { 
      UNREFERENCED_PARAMETER(nError); 
      SetEvent(m_waitEvent); 
      L_UINT32 uSecureMode = this->GetSecureMode(); 
      switch(uSecureMode) 
      { 
      case DICOM_SECURE_NONE: 
         LogMessage(TEXT("CMyClient::OnSecureLinkReady: DICOM_SECURE_NONE")); 
         break; 
      case DICOM_SECURE_ISCL: 
         LogMessage(TEXT("CMyClient::OnSecureLinkReady: DICOM_SECURE_ISCL")); 
         break; 
      case DICOM_SECURE_TLS: 
         LogMessage(TEXT("CMyClient::OnSecureLinkReady: DICOM_SECURE_TLS")); 
         break; 
      } 
   } 
 
   L_VOID CMyClient::OnReceiveAssociateAccept  (LDicomAssociate *pPDU) 
   { 
      UNREFERENCED_PARAMETER(pPDU); 
      SetEvent(m_waitEvent); 
      LogMessage(TEXT("CMyClient::OnReceiveAssociateAccept")); 
   } 
    
   L_VOID CMyClient::OnReceiveCEchoResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus) 
   { 
      SetEvent(m_waitEvent); 
      L_TCHAR szMsg[200] = {0}; 
 
      if (pszClass == NULL) 
      { 
         pszClass = TEXT(""); 
      } 
      wsprintf(szMsg, TEXT("CMyClient::OnReceiveCEchoResponse: \n\tnPresentationID[%d], \n\tnMessageID[%d], \n\tpszClass[%s], \n\tnStatus[%d]"), nPresentationID, nMessageID, pszClass, nStatus);  
      LogMessage(szMsg); 
   } 
 
   L_VOID CMyClient::OnReceiveReleaseResponse() 
   { 
      SetEvent(m_waitEvent); 
      LogMessage(TEXT("CMyClient::OnReceiveReleaseResponse")); 
   } 
 
   L_UINT32 CMyClient::GetChallengeISCL(L_UINT64 *pChallenge, L_UINT64 nParameter) 
   { 
      UNREFERENCED_PARAMETER(nParameter); 
      *pChallenge = 0x0123456789ABCDE1; 
      return 0; 
   } 
   L_UINT32 CMyClient::InternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 *pResponse, L_UINT64 nParameter) 
   { 
      UNREFERENCED_PARAMETER(nParameter); 
      *pResponse = nChallenge + 1; 
      return 0; 
   } 
 
   L_UINT32 CMyClient::ExternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 nResponse, L_UINT64 nParameter) 
   { 
      UNREFERENCED_PARAMETER(nParameter); 
      if (nResponse == nChallenge + 1) 
         return 0; 
      else 
         return 1; 
   } 
 
   L_BOOL CMyClient::Wait(DWORD timeout) 
   { 
      L_BOOL bRet = MessageLoop(m_waitEvent,  timeout);   
      return bRet; 
   } 
 
   // ******************************************************************************************* 
   // Server Connection Class  
   // 
   // When a client connects, CMyServer creates a new instance of the CMyServerConnection class  
   // and accepts the connection.   
   // ******************************************************************************************* 
   class CMyServerConnection : public LDicomNet 
   { 
   public: 
      CMyServerConnection(L_INT32 nMode): LDicomNet(NULL, nMode) 
      { 
      } 
      ~CMyServerConnection(void) 
      { 
      } 
 
      // Server 
      L_VOID OnReceiveAssociateRequest(LDicomAssociate *pPDU); 
      L_VOID OnReceiveCEchoRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass); 
      L_VOID OnReceiveReleaseRequest(); 
 
      // ISCL Security Events 
      L_UINT32 GetChallengeISCL(L_UINT64 *pChallenge, L_UINT64 nParameter); 
      L_UINT32 InternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 *pResponse, L_UINT64 nParameter); 
      L_UINT32 ExternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 nResponse, L_UINT64 nParameter); 
   }; 
 
   #define SIZEINWORD(p) sizeof(p)/sizeof(L_TCHAR) 
   L_VOID CMyServerConnection::OnReceiveAssociateRequest(LDicomAssociate *pPDU) 
   { 
      LogMessage(TEXT("\tCMyServerConnection::OnReceiveAssociateRequest")); 
 
      //check the version, if not 1, reject it 
      if (pPDU->GetVersion() != 1) 
      { 
         LogMessage(TEXT("\tCMyServerConnection::SendAssociateReject")); 
         SendAssociateReject( 
            PDU_REJECT_RESULT_PERMANENT,  
            PDU_REJECT_SOURCE_USER,  
            PDU_REJECT_REASON_UNKNOWN 
            ); 
      } 
      else 
      {         
         LDicomAssociate DicomAssociate(FALSE); 
 
         //Copy presentation objects from received 
         //Reply that we only support the first Transfer Syntax from the received hPDU 
         L_TCHAR szTransfer[PDU_MAX_UID_SIZE+1] = {0}; 
         L_TCHAR szAbstract[PDU_MAX_UID_SIZE+1] = {0}; 
         L_INT iPresentationCount = pPDU->GetPresentationCount(); 
         for (L_UCHAR i = 0; i<iPresentationCount; i++) 
         { 
            L_UCHAR nId = pPDU->GetPresentation(i); 
            pPDU->GetTransfer(nId, 0, szTransfer, PDU_MAX_UID_SIZE+1); 
            L_UCHAR nResult = PDU_ACCEPT_RESULT_SUCCESS; 
            pPDU->GetAbstract(nId, szAbstract, PDU_MAX_UID_SIZE+1); 
            DicomAssociate.AddPresentation( nId, nResult, szAbstract); 
            DicomAssociate.AddTransfer( nId, szTransfer); 
         } 
 
         LogMessage(TEXT("\tCMyServerConnection::SendAssociateAccept")); 
         SendAssociateAccept(&DicomAssociate); 
      } 
   } 
 
   L_VOID CMyServerConnection::OnReceiveCEchoRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass) 
   { 
      LogMessage(TEXT("\tCMyServerConnection::OnReceiveCEchoRequest")); 
      SendCEchoResponse(nPresentationID, nMessageID, pszClass, COMMAND_STATUS_SUCCESS); 
   } 
 
   L_VOID CMyServerConnection::OnReceiveReleaseRequest() 
   { 
      LogMessage(TEXT("\tCMyServerConnection::OnReceiveReleaseRequest")); 
      LogMessage(TEXT("\tCMyServerConnection::SendReleaseResponse")); 
      SendReleaseResponse(); 
   } 
 
   L_UINT32 CMyServerConnection::GetChallengeISCL(L_UINT64 *pChallenge, L_UINT64 nParameter) 
   { 
      UNREFERENCED_PARAMETER(nParameter); 
      *pChallenge = 0x0123456789ABCDE1; 
      return 0; 
   } 
   L_UINT32 CMyServerConnection::InternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 *pResponse, L_UINT64 nParameter) 
   { 
      UNREFERENCED_PARAMETER(nParameter); 
      *pResponse = nChallenge + 1; 
      return 0; 
   } 
 
   L_UINT32 CMyServerConnection::ExternalAuthenticateISCL  (L_UINT64 nChallenge, L_UINT64 nResponse, L_UINT64 nParameter) 
   { 
      UNREFERENCED_PARAMETER(nParameter); 
      if (nResponse == nChallenge + 1) 
         return 0; 
      else 
         return 1; 
   } 
 
   // ******************************************************************************************* 
   // Server Class  
   // 
   // Listens for connections 
   // When a client connects, this class creates a CMyServerConnection and accepts the connection 
   // ******************************************************************************************* 
   class CMyServer : public LDicomNet 
   { 
   public: 
      CMyServer(L_INT32 nMode): LDicomNet(NULL, nMode) 
      { 
         m_pServerConnection = NULL; 
      } 
 
      ~CMyServer(void) 
      { 
         if (m_pServerConnection != NULL) 
         { 
            delete m_pServerConnection; 
         } 
      } 
 
      L_VOID OnAccept       (L_INT nError); 
      L_VOID OnClose        (L_INT nError, LDicomNet *pServerConnection); 
 
      CMyServerConnection *m_pServerConnection; 
   }; 
 
   L_VOID CMyServer::OnAccept(L_INT nError) 
   { 
      LogMessage(TEXT("\tCMyServer::OnAccept")); 
      if (nError != DICOM_SUCCESS) 
      { 
         return; 
      } 
 
      if (m_pServerConnection != NULL) 
      { 
         delete m_pServerConnection; 
         m_pServerConnection = NULL; 
      } 
 
      m_pServerConnection = new CMyServerConnection(DICOM_SECURE_ISCL); 
      if (m_pServerConnection == NULL) 
      { 
         return; 
      } 
      SetupISCL(m_pServerConnection); 
 
      nError = LDicomNet::Accept(m_pServerConnection); 
      if (nError != DICOM_SUCCESS) 
      { 
         delete m_pServerConnection; 
         return; 
      } 
   } 
 
   L_VOID CMyServer::OnClose(L_INT nError, LDicomNet *pClient) 
   { 
      LogMessage(TEXT("\tCMyServer::OnClose")); 
      pClient->OnClose(nError, pClient); 
      delete (CMyClient *)pClient; 
   } 
 
   // ******************************************************************************************* 
   // Sample starts here  
   // ******************************************************************************************* 
   #define WaitForProcessing() \ 
   { \ 
      if (!client.Wait()) \ 
      { \ 
         LogMessage(TEXT("Timeout: client.Connect")); \ 
         nRet = DICOM_ERROR_NET_TIME_OUT; \ 
         goto Cleanup; \ 
      } \ 
   }  
 
   L_INT LDicomNet_IsISCLQueueEmptyExample() 
   { 
      LogMessage(TEXT("\n\n *** IsISCLQueueEmptySample ***")); 
 
      L_TCHAR *pszServerAddress = TEXT("127.0.0.1"); 
      L_UINT uServerPort = 110; 
      L_INT nRet = DICOM_SUCCESS; 
 
      LDicomNet::StartUp(); 
 
      CMyClient client(DICOM_SECURE_ISCL); 
      CMyServer server(DICOM_SECURE_ISCL); 
 
      SetupISCL(&client); 
      
      nRet = server.Listen(pszServerAddress, uServerPort, 5); 
 
      LogMessage(TEXT("CMyClient::Connect")); 
      client.Connect(NULL, 0, pszServerAddress, uServerPort); 
      if (!client.Wait(2000)) 
      { 
         if (!client.IsConnected()) 
         { 
            LogMessage(TEXT("Timeout: client.Connect"));  
            nRet = DICOM_ERROR_NET_TIME_OUT; 
            goto Cleanup; 
         } 
      } 
 
      if (nRet == DICOM_SUCCESS) 
      { 
         //create the Associate Class as Request 
         LDicomAssociate dicomAssociateRequest(TRUE); 
         dicomAssociateRequest.Default(); 
 
         // Send A-Associate-RQ message 
         dicomAssociateRequest.SetCalled(TEXT("LEAD_SERVER")); 
         dicomAssociateRequest.SetCalling(TEXT("LEAD_CLIENT")); 
 
         LogMessage(TEXT("CMyClient::SendAssociateRequest")); 
         nRet = client.SendAssociateRequest(&dicomAssociateRequest); 
         if (!client.Wait(5000)) 
         { 
            LogMessage(TEXT("Timeout: client.Connect"));  
            nRet = DICOM_ERROR_NET_TIME_OUT; 
            goto Cleanup; 
         } 
      } 
 
      L_UCHAR nPresentationID = client.GetAssociate()->FindAbstract(UID_VERIFICATION_CLASS); 
      L_UINT16 uUniqueID = 99; 
 
      LogMessage(TEXT("CMyClient::SendCEchoRequest")); 
      client.SendCEchoRequest( nPresentationID, uUniqueID, UID_VERIFICATION_CLASS); 
 
      L_BOOL bRet = client.IsISCLQueueEmpty(); 
      if(bRet == TRUE) 
      { 
         LogMessage(TEXT("ISCL queue is empty")); 
      } 
      else 
      { 
         LogMessage(TEXT("ISCL queue is not empty")); 
      } 
      WaitForProcessing(); 
 
 
      LogMessage(TEXT("CMyClient::SendReleaseRequest")); 
      client.SendReleaseRequest(); 
      WaitForProcessing(); 
 
Cleanup: 
      client.Close(); 
      server.Close(); 
 
      LDicomNet::ShutDown(); 
 
      return nRet; 
   } 
 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help