L_DicomListen

#include "ltdic.h"

L_LTDIC_API L_INT L_DicomListen(hNet, pszHostAddress, nHostPort, nNbPeers)

Establishes a connection to listen for incoming connection requests.

Parameters

HDICOMNET hNet

A DICOM Network handle. This is the handle returned from the L_DicomCreateNet function.

L_TCHAR * pszHostAddress

Character string that contains the IP address of the host computer (the server's address).

L_UINT nHostPort

Port number of the host (the server's port).

L_INT nNbPeers

Value passed to the WinSock listen() function for the backlog parameter that limits the size of the queue for waiting connections.

Returns

Value Meaning
DICOM_SUCCESS The function was successful.
>0 An error occurred. Refer to Return Codes.

Comments

If pszHostAddress is " or NULL, the IP address will be the local computer's address.

If pszHostAddress is "*", the IP address will be all of the local computer's addresses.  This is useful if the local computer has more than one network interface and address.

If nHostPort is 0, the port number will be the number of the first available port.

To connect to a server as a client, you must first create and initialize a handle to the DICOM Network using L_DicomCreateNet. Next, set the callback functions you will use by calling L_DicomSetCallback. Then call L_DicomConnect or L_DicomConnectExt to establish the connection.

To use your computer as a server, you must first create and initialize a handle to the DICOM Network using L_DicomCreateNet. Next, set the callback functions you will use by calling L_DicomSetCallback. Then call L_DicomListen or L_DicomListenExt to listen for incoming connection requests.

L_DicomConnectExt and L_DicomListenExt support both iPv4 and iPv6.

The nNbPeers parameter designates the size of the backlog parameter used by the WinSock listen() function. As an example, suppose that the value is set to 3 and that 4 people try to connect at exactly the same time. In such a case, all 4 will be rejected because the connection backlog queue is full. But if one of the connections has been accepted by the time the 4th is made, then all will work.

To determine the number of connected clients and impose a maximum number of connections, perform the following steps:

  1. Use the L_GetClientCount function in the "OnReceiveAssociateRequest" handler.

  2. Compare that value with the maximum number of connections allowed.

  3. If the number of connected clients is greater than the maximum number of connections allowed, send a "SendAssociateReject" command to the client trying to connect.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

L_VOID EXT_CALLBACK OnConnect(HDICOMNET hNet, L_INT nError, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnClose(HDICOMNET hNet, L_INT nError, HDICOMNET hPeer, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceive(HDICOMNET hNet, L_INT nError, L_UCHAR nType, L_UCHAR* pBuffer, L_UINT32 nBytes, L_VOID* pUserData); 
L_VOID EXT_CALLBACK OnSend(HDICOMNET hNet, L_INT nError, L_UCHAR nType, L_UINT32 nBytes, L_VOID* pUserData); 
L_VOID EXT_CALLBACK OnReceiveAssociateRequest(HDICOMNET hNet, HDICOMPDU hAssociate, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveReleaseRequest(HDICOMNET hNet, L_VOID* pUserData); 
L_VOID EXT_CALLBACK OnReceiveReleaseResponse(HDICOMNET hNet, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveAbort(HDICOMNET hNet, L_UCHAR nSource, L_UCHAR nReason, L_VOID* pUserData); 
L_VOID EXT_CALLBACK OnReceiveData(HDICOMNET hNet, L_UCHAR nID, HDICOMDS hCS, HDICOMDS hDS, L_VOID* pUserData); 
L_VOID EXT_CALLBACK OnReceiveAssociateAccept(HDICOMNET hNet, HDICOMPDU hAssociate, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveAssociateReject(HDICOMNET hNet, L_UCHAR nResult, L_UCHAR nSource, L_UCHAR nReason, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCStoreRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nPriority, L_TCHAR *pszMoveAE, L_UINT16 nMoveMessageID, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCStoreResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCFindRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nPriority, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCFindResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCGetRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nPriority, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCGetResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus, L_UINT16 nRemaining, L_UINT16 nCompleted, L_UINT16 nFailed, L_UINT16 nWarning, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCMoveRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR* pszClass, L_UINT16 nPriority, L_TCHAR* pszMoveAE, HDICOMDS hDS, L_VOID* pUserData); 
L_VOID EXT_CALLBACK OnReceiveCMoveResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus, L_UINT16 nRemaining, L_UINT16 nCompleted, L_UINT16 nFailed, L_UINT16 nWarning, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCCancelRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveCEchoRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR* pszClass, L_VOID* pUserData); 
L_VOID EXT_CALLBACK OnReceiveCEchoResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNReportRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nEvent, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNReportResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, L_UINT16 nEvent, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNGetRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT32 *pnAttribute, L_UINT32 nCount, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNGetResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNSetRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNSetResponse(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNActionRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nAction, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNActionResponse  (HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, L_UINT16 nAction, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNCreateRequest(HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNCreateResponse  (HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, HDICOMDS hDS, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNDeleteRequest   (HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveNDeleteResponse  (HDICOMNET hNet, L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, L_VOID *pUserData); 
L_VOID EXT_CALLBACK OnReceiveUnknown(HDICOMNET hNet, L_UCHAR nPresentationID, HDICOMDS hCS, HDICOMDS hDS, L_VOID *pUserData); 
 
L_VOID EXT_CALLBACK OnAccept( 
   HDICOMNET hNet, 
   L_INT nError, 
   L_VOID* pUserData) 
{ 
   L_TCHAR szMsg[800]; 
   L_TCHAR szTemp[800]; 
   HDICOMNET hClient; 
   L_INT32 lClients; 
   L_TCHAR szURL[200]; 
   L_UINT uPort; 
   DICOMNETCALLBACK cb; 
   L_INT nRet; 
 
   UNREFERENCED_PARAMETER(pUserData); 
 
   wsprintf(szMsg, TEXT("***NetAccept Event ***\n nStatus[%d]\n"), nError); 
 
   if (nError != DICOM_SUCCESS) 
   { 
      MessageBox(NULL, szMsg, TEXT("Accept"), MB_OK); 
      return; 
   } 
 
   /* accept the connection attempt */ 
   hClient = L_DicomCreateNet(NULL, DICOM_SECURE_NONE); 
   L_DicomAccept(hNet, hClient); 
 
   /* set the callbacks */ 
   memset(&cb, 0, sizeof(DICOMNETCALLBACK)); 
   cb.pfnConnect = (CONNECTCALLBACK)OnConnect; 
   cb.pfnClose = (CLOSECALLBACK)OnClose; 
   cb.pfnReceive = (RECEIVECALLBACK)OnReceive; 
   cb.pfnSend = (SENDCALLBACK)OnSend; 
   cb.pfnReceiveAssociateRequest = (RECEIVEASSOCIATEREQUESTCALLBACK)OnReceiveAssociateRequest; 
   cb.pfnReceiveReleaseRequest = (RECEIVERELEASEREQUESTCALLBACK)OnReceiveReleaseRequest; 
   cb.pfnReceiveReleaseResponse  = (RECEIVERELEASERESPONSECALLBACK)OnReceiveReleaseResponse; 
   cb.pfnReceiveAbort = (RECEIVEABORTCALLBACK)OnReceiveAbort; 
   cb.pfnReceiveData = (RECEIVEDATACALLBACK)OnReceiveData; 
   cb.pfnReceiveAssociateAccept  = (RECEIVEASSOCIATEACCEPTCALLBACK)OnReceiveAssociateAccept; 
   cb.pfnReceiveAssociateReject = (RECEIVEASSOCIATEREJECTCALLBACK)OnReceiveAssociateReject; 
   cb.pfnReceiveCStoreRequest = (RECEIVECSTOREREQUESTCALLBACK)OnReceiveCStoreRequest; 
   cb.pfnReceiveCStoreResponse = (RECEIVECSTORERESPONSECALLBACK)OnReceiveCStoreResponse; 
   cb.pfnReceiveCFindRequest = (RECEIVECFINDREQUESTCALLBACK)OnReceiveCFindRequest; 
   cb.pfnReceiveCFindResponse = (RECEIVECFINDRESPONSECALLBACK)OnReceiveCFindResponse; 
   cb.pfnReceiveCGetRequest = (RECEIVECGETREQUESTCALLBACK)OnReceiveCGetRequest; 
   cb.pfnReceiveCGetResponse = (RECEIVECGETRESPONSECALLBACK)OnReceiveCGetResponse; 
   cb.pfnReceiveCMoveRequest = (RECEIVECMOVEREQUESTCALLBACK)OnReceiveCMoveRequest; 
   cb.pfnReceiveCMoveResponse = (RECEIVECMOVERESPONSECALLBACK)OnReceiveCMoveResponse; 
   cb.pfnReceiveCCancelRequest = (RECEIVECCANCELREQUESTCALLBACK)OnReceiveCCancelRequest; 
   cb.pfnReceiveCEchoRequest = (RECEIVECECHOREQUESTCALLBACK)OnReceiveCEchoRequest; 
   cb.pfnReceiveCEchoResponse = (RECEIVECECHORESPONSECALLBACK)OnReceiveCEchoResponse; 
   cb.pfnReceiveNReportRequest = (RECEIVENREPORTREQUESTCALLBACK)OnReceiveNReportRequest; 
   cb.pfnReceiveNReportResponse = (RECEIVENREPORTRESPONSECALLBACK)OnReceiveNReportResponse; 
   cb.pfnReceiveNGetRequest = (RECEIVENGETREQUESTCALLBACK)OnReceiveNGetRequest; 
   cb.pfnReceiveNGetResponse = (RECEIVENGETRESPONSECALLBACK)OnReceiveNGetResponse; 
   cb.pfnReceiveNSetRequest = (RECEIVENSETREQUESTCALLBACK)OnReceiveNSetRequest; 
   cb.pfnReceiveNSetResponse = (RECEIVENSETRESPONSECALLBACK)OnReceiveNSetResponse; 
   cb.pfnReceiveNActionRequest = (RECEIVENACTIONREQUESTCALLBACK)OnReceiveNActionRequest; 
   cb.pfnReceiveNActionResponse = (RECEIVENACTIONRESPONSECALLBACK)OnReceiveNActionResponse; 
   cb.pfnReceiveNCreateRequest = (RECEIVENCREATEREQUESTCALLBACK)OnReceiveNCreateRequest; 
   cb.pfnReceiveNCreateResponse = (RECEIVENCREATERESPONSECALLBACK)OnReceiveNCreateResponse; 
   cb.pfnReceiveNDeleteRequest = (RECEIVENDELETEREQUESTCALLBACK)OnReceiveNDeleteRequest; 
   cb.pfnReceiveNDeleteResponse = (RECEIVENDELETERESPONSECALLBACK)OnReceiveNDeleteResponse; 
   cb.pfnReceiveUnknown = (RECEIVEUNKNOWNCALLBACK)OnReceiveUnknown; 
   cb.pUserData = NULL; 
   L_DicomSetCallback(hClient, &cb); 
 
   lstrcat(szMsg, TEXT("Accepted\n")); 
 
   /* display some information about the connection */ 
   nRet = L_DicomGetHostInfo(hNet, szURL, 200, &uPort); 
   if (nRet != DICOM_SUCCESS) 
   { 
      MessageBox(NULL, TEXT("Error Inside Callback Function"), TEXT("Accept"), MB_OK); 
      return; 
   } 
 
   wsprintf(szTemp, TEXT("HostAddress[%s]\nHostPort[%d]\n"), szURL, uPort); 
   lstrcat(szMsg, szTemp); 
 
   /* get the latest client */ 
   lClients = L_DicomGetClientCount(hNet); 
   hClient  = L_DicomGetClient(hNet, lClients - 1); 
   wsprintf(szTemp, TEXT("ClientCount[%d]\nLatest Client[%x]\n"), lClients, hClient); 
   lstrcat(szMsg, szTemp); 
 
   nRet = L_DicomGetPeerInfo(hClient, szURL, 200, &uPort); 
   if (nRet != DICOM_SUCCESS) 
   { 
      MessageBox(NULL, TEXT("Error Inside Callback Function"), TEXT("Accept"), MB_OK); 
      return; 
   } 
 
   wsprintf(szTemp, TEXT("PeerAddress[%s]\nPeerPort[%d]\n"), szURL, uPort); 
   lstrcat(szMsg, szTemp); 
 
   MessageBox(NULL, szMsg, TEXT("Accept"), MB_OK); 
 
   /* reject the connection if we do not like the address */ 
   if(lstrcmp(szURL, TEXT("207.238.49.199")) != 0) 
   { 
      /* close the connection */ 
      L_DicomClose(hClient); 
   } 
} 
 
 
L_VOID  EXT_CALLBACK OnSend( 
   HDICOMNET hNet, 
   L_INT nError, 
   L_UCHAR nType, 
   L_UINT32 nBytes, 
   L_VOID* pUserData) 
{ 
   L_TCHAR szText[80]; 
   UNREFERENCED_PARAMETER(hNet); 
   UNREFERENCED_PARAMETER(nError); 
   UNREFERENCED_PARAMETER(nType); 
   UNREFERENCED_PARAMETER(pUserData); 
 
   wsprintf(szText, TEXT("Sent Data - %u\n"), nBytes); 
   OutputDebugString(szText); 
} 
 
L_VOID  EXT_CALLBACK OnReceive( 
   HDICOMNET hNet, 
   L_INT nError, 
   L_UCHAR nType, 
   L_UCHAR* pBuffer, 
   L_UINT32 nBytes, 
   L_VOID* pUserData) 
{ 
   L_TCHAR szText[80]; 
   UNREFERENCED_PARAMETER(hNet); 
   UNREFERENCED_PARAMETER(nError); 
   UNREFERENCED_PARAMETER(nType); 
   UNREFERENCED_PARAMETER(pBuffer); 
   UNREFERENCED_PARAMETER(pUserData); 
 
   wsprintf(szText, TEXT("Received Data - %u"), nBytes); 
   OutputDebugString(szText); 
} 
 
L_VOID  EXT_CALLBACK OnReceiveAssociateRequest( 
   HDICOMNET hNet, 
   HDICOMPDU hAssociate, 
   L_VOID *pUserData) 
{ 
   L_TCHAR szMsg[800]; 
   L_UCHAR i; 
   L_UCHAR nId; 
   L_UCHAR nResult; 
   HDICOMPDU hPDU=NULL; 
   L_INT nRet; 
   UNREFERENCED_PARAMETER(pUserData); 
 
   /* we have received an AssociateRequest */ 
   lstrcpy(szMsg, TEXT("*** NetReceiveAssociateRequest Event ***\n")); 
     
   /* check the version, if not 1, reject it */ 
   if(L_DicomGetVersion(hAssociate) != 1) 
   { 
      nRet = L_DicomSendAssociateReject( 
         hNet, 
         PDU_REJECT_RESULT_PERMANENT, 
         PDU_REJECT_SOURCE_USER, 
         PDU_REJECT_REASON_UNKNOWN); 
      if (nRet != DICOM_SUCCESS) 
            lstrcpy(szMsg, TEXT("Error inside callback\n")); 
      else 
         lstrcat(szMsg, TEXT("\nSent Associate Regject!\n")); 
   } 
   else 
   { 
      /* send associate accept class back */ 
      hPDU = L_DicomCreateAssociate(FALSE); 
      L_DicomResetAssociate(hPDU, FALSE); 
 
      /* copy all presentation objects from received hPDU   */ 
      /* also, reply that we only support the first Transfer*/ 
      /* Syntax from the received hPDU                      */ 
 
     L_TCHAR szTransfer[PDU_MAX_UID_SIZE +1]; 
 
     L_TCHAR szAbstract[PDU_MAX_UID_SIZE +1]; 
      for(i = 0; i<L_DicomGetPresentationCount(hAssociate); i++) 
      { 
         nId = L_DicomGetPresentation(hAssociate, i); 
         L_DicomGetTransfer(hAssociate, nId, 0, szTransfer, PDU_MAX_UID_SIZE +1); 
         nResult = PDU_ACCEPT_RESULT_SUCCESS; 
         L_DicomGetAbstract(hAssociate, nId, szAbstract, PDU_MAX_UID_SIZE +1); 
         nRet = L_DicomAddPresentation(hPDU, nId, nResult, szAbstract); 
         if (nRet != DICOM_SUCCESS) 
            lstrcpy(szMsg, TEXT("Error inside callback\n")); 
 
         nRet =  L_DicomAddTransfer(hPDU, nId, szTransfer); 
         if (nRet != DICOM_SUCCESS) 
            lstrcpy(szMsg, TEXT("Error inside callback\n")); 
      } 
 
      nRet = L_DicomSendAssociateAccept(hNet, hPDU); 
      if (nRet != DICOM_SUCCESS) 
         lstrcpy(szMsg, TEXT("Error inside callback\n")); 
 
      if (nRet == DICOM_SUCCESS) 
      { 
         L_DicomFreeAssociate(hPDU); 
         lstrcat(szMsg, TEXT("\nSent Associate Accept.\n")); 
      } 
   } 
   MessageBox(NULL, szMsg, TEXT("OnReceiveAssociateRequest"), MB_OK); 
} 
 
L_VOID  EXT_CALLBACK OnReceiveReleaseRequest( 
   HDICOMNET hNet, 
   L_VOID* pUserData) 
{ 
   L_TCHAR szMsg[200]; 
   UNREFERENCED_PARAMETER(pUserData); 
 
   lstrcpy(szMsg, TEXT("*** NetReceiveRelease Event ***\n")); 
   L_DicomSendReleaseResponse(hNet); 
   lstrcat(szMsg, TEXT("Sent Release Response.\n")); 
   MessageBox(NULL, szMsg, TEXT("OnReceiveReleaseRequest"), MB_OK); 
} 
 
L_VOID  EXT_CALLBACK OnReceiveAbort( 
   HDICOMNET hNet, 
   L_UCHAR nSource, 
   L_UCHAR nReason, 
   L_VOID* pUserData) 
{ 
   L_TCHAR szMsg[200]; 
   UNREFERENCED_PARAMETER(hNet); 
   UNREFERENCED_PARAMETER(pUserData); 
 
   wsprintf(szMsg, TEXT("*** OnReceiveAbort ***\nSource[%d]\nReason[%d]"), nSource, nReason); 
   MessageBox(NULL, szMsg, TEXT("OnReceiveAbort"), MB_OK); 
} 
 
L_VOID  EXT_CALLBACK OnReceiveData( 
   HDICOMNET hNet, 
   L_UCHAR nID, 
   HDICOMDS hCS, 
   HDICOMDS hDS, 
   L_VOID* pUserData) 
{ 
   /* This example saves the Data Set in a file */ 
   L_TCHAR szMsg[200]; 
   UNREFERENCED_PARAMETER(hNet); 
   UNREFERENCED_PARAMETER(hCS); 
   UNREFERENCED_PARAMETER(pUserData); 
 
   wsprintf(szMsg, TEXT("*** OnReceiveData ***\nnID[%d]"), nID); 
   if(!hDS) 
      lstrcat(szMsg, TEXT("\nData is a command set only!")); 
   else 
   { 
      lstrcat(szMsg, TEXT("Data includes a data set - saved to disk!")); 
      L_DicomSaveDS(hDS, MAKE_IMAGE_PATH(TEXT("Result.dcm")), 0); 
   } 
   MessageBox(NULL, szMsg, TEXT("OnReceiveData"), MB_OK); 
} 
 
L_INT DicomListenExample(L_VOID) 
{ 
   L_INT nRet; 
   DICOMNETCALLBACK cb; 
   HDICOMNET hServer; 
 
   /* start the network */ 
   nRet = L_DicomStartUp(); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
 
   hServer = L_DicomCreateNet(MAKE_IMAGE_PATH(TEXT("")), DICOM_SECURE_NONE); 
 
   /* set the callbacks */ 
   memset(&cb, 0, sizeof(DICOMNETCALLBACK)); 
   cb.pfnConnect = (CONNECTCALLBACK)OnConnect; 
   cb.pfnAccept = (ACCEPTCALLBACK)OnAccept; 
   cb.pfnClose = (CLOSECALLBACK)OnClose; 
   cb.pfnReceive = (RECEIVECALLBACK)OnReceive; 
   cb.pfnSend = (SENDCALLBACK)OnSend; 
   cb.pfnReceiveAssociateRequest = (RECEIVEASSOCIATEREQUESTCALLBACK)OnReceiveAssociateRequest; 
   cb.pfnReceiveReleaseRequest = (RECEIVERELEASEREQUESTCALLBACK)OnReceiveReleaseRequest; 
   cb.pfnReceiveReleaseResponse = (RECEIVERELEASERESPONSECALLBACK)OnReceiveReleaseResponse; 
   cb.pfnReceiveAbort = (RECEIVEABORTCALLBACK)OnReceiveAbort; 
   cb.pfnReceiveData = (RECEIVEDATACALLBACK)OnReceiveData; 
   cb.pfnReceiveAssociateAccept = (RECEIVEASSOCIATEACCEPTCALLBACK)OnReceiveAssociateAccept; 
   cb.pfnReceiveAssociateReject = (RECEIVEASSOCIATEREJECTCALLBACK)OnReceiveAssociateReject; 
   cb.pfnReceiveCStoreRequest = (RECEIVECSTOREREQUESTCALLBACK)OnReceiveCStoreRequest; 
   cb.pfnReceiveCStoreResponse = (RECEIVECSTORERESPONSECALLBACK)OnReceiveCStoreResponse; 
   cb.pfnReceiveCFindRequest = (RECEIVECFINDREQUESTCALLBACK)OnReceiveCFindRequest; 
   cb.pfnReceiveCFindResponse = (RECEIVECFINDRESPONSECALLBACK)OnReceiveCFindResponse; 
   cb.pfnReceiveCGetRequest = (RECEIVECGETREQUESTCALLBACK)OnReceiveCGetRequest; 
   cb.pfnReceiveCGetResponse = (RECEIVECGETRESPONSECALLBACK)OnReceiveCGetResponse; 
   cb.pfnReceiveCMoveRequest = (RECEIVECMOVEREQUESTCALLBACK)OnReceiveCMoveRequest; 
   cb.pfnReceiveCMoveResponse = (RECEIVECMOVERESPONSECALLBACK)OnReceiveCMoveResponse; 
   cb.pfnReceiveCCancelRequest = (RECEIVECCANCELREQUESTCALLBACK)OnReceiveCCancelRequest; 
   cb.pfnReceiveCEchoRequest = (RECEIVECECHOREQUESTCALLBACK)OnReceiveCEchoRequest; 
   cb.pfnReceiveCEchoResponse = (RECEIVECECHORESPONSECALLBACK)OnReceiveCEchoResponse; 
   cb.pfnReceiveNReportRequest = (RECEIVENREPORTREQUESTCALLBACK)OnReceiveNReportRequest; 
   cb.pfnReceiveNReportResponse = (RECEIVENREPORTRESPONSECALLBACK)OnReceiveNReportResponse; 
   cb.pfnReceiveNGetRequest = (RECEIVENGETREQUESTCALLBACK)OnReceiveNGetRequest; 
   cb.pfnReceiveNGetResponse = (RECEIVENGETRESPONSECALLBACK)OnReceiveNGetResponse; 
   cb.pfnReceiveNSetRequest = (RECEIVENSETREQUESTCALLBACK)OnReceiveNSetRequest; 
   cb.pfnReceiveNSetResponse = (RECEIVENSETRESPONSECALLBACK)OnReceiveNSetResponse; 
   cb.pfnReceiveNActionRequest = (RECEIVENACTIONREQUESTCALLBACK)OnReceiveNActionRequest; 
   cb.pfnReceiveNActionResponse = (RECEIVENACTIONRESPONSECALLBACK)OnReceiveNActionResponse; 
   cb.pfnReceiveNCreateRequest = (RECEIVENCREATEREQUESTCALLBACK)OnReceiveNCreateRequest; 
   cb.pfnReceiveNCreateResponse = (RECEIVENCREATERESPONSECALLBACK)OnReceiveNCreateResponse; 
   cb.pfnReceiveNDeleteRequest = (RECEIVENDELETEREQUESTCALLBACK)OnReceiveNDeleteRequest; 
   cb.pfnReceiveNDeleteResponse = (RECEIVENDELETERESPONSECALLBACK)OnReceiveNDeleteResponse; 
   cb.pfnReceiveUnknown = (RECEIVEUNKNOWNCALLBACK)OnReceiveUnknown; 
   cb.pUserData = NULL; 
   L_DicomSetCallback(hServer, &cb); 
 
   /* create a server to accept up to 25 clients */ 
   nRet = L_DicomListen(hServer, NULL, 1005, 25); 
 
   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 API Help