LDicomNet::OnConnect

#include "ltdic.h"

virtual L_VOID LDicomNet::OnConnect(nError)

L_INT nError;

/* error code */

Notifies the SCU that the connection attempt is complete. This function is available in the Medical Imaging Suite Toolkit.

Parameter

Description

nError

Error code. Refer to Return Codes.

Returns

None.

Comments

A call to this function is generated on an SCU when an SCP calls LDicomNet::Accept. It is generated whether or not the connection attempt is successful. It is also generated when a connection attempt has timed-out.

To customize this function, you must derive a class from LDicomNet and override this function.

A DICOM Association must be established between an SCU and an SCP before any DICOM messages or data can be transmitted between them. For more information on creating a DICOM Association, refer to Creating a DICOM Associate Connection.

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LDicomNet::Connect, LDicomNet::Accept, LDicomNet::OnConnect

Topics:

Creating a DICOM Network Connection

Example

//LMyDicomNet is a class derived from LDicomNet

//In class LMyDicomNet, all events (virtual functions OnXXX()) have been

//overridden so that they can be processed. Each event displays a MessageBox

//identifying the event, the IP that generated the event, the IP that received the event

//any other relevant data

//For the entire derived class, see (hyperlink)LMyDicomNet class

//OnConnect()--client receives this event

/*<struct>*/
#ifdef LMYDICOMNET
{
class LMyDicomNet : public LDicomNet
public:
   L_INT m_nProcess;
   L_INT m_nClientOrServer;
   L_INT m_nDataCommand;
   L_INT m_FileCount;
   LMyDicomNet (L_TCHAR *pszPath, L_INT32 nMode);
   LMyDicomNet (L_TCHAR *pszPath, L_INT32 nMode, L_BOOL bReserved);
   virtual ~LMyDicomNet ();
   L_VOID LMyDicomNet::OnAccept(L_INT nError);//OnAccept
   L_VOID LMyDicomNet::OnClose(L_INT nError, LDicomNet *pNet);//OnClose
   L_VOID LMyDicomNet::OnConnect(L_INT nError);//OnConnect
   L_VOID LMyDicomNet::OnNonSecureReceivedISCL(L_VOID *pBuffer, L_UINT32 nLength);//OnNonSecureReceivedISCL
   L_VOID LMyDicomNet::OnNonSecureSendISCL(L_INT nError, L_UCHAR nType, L_UINT32 nLength);//OnNonSecureSendISCL
   L_VOID LMyDicomNet::OnReceive(L_INT nError, L_UCHAR nType, L_UCHAR *pBuffer, L_UINT32 nBytes);//OnReceive
   L_VOID LMyDicomNet::OnReceive2(L_INT nError, L_UCHAR nType, L_UCHAR *pBuffer, L_UINT32 nBytes);//OnReceive
   L_VOID LMyDicomNet::OnReceiveAbort(L_UCHAR nSource, L_UCHAR nReason);//OnReceiveAbort
   L_VOID LMyDicomNet::OnReceiveAssociateAccept(LDicomAssociate *pPDU);//OnReceiveAssociateAccept
   L_VOID LMyDicomNet::OnReceiveAssociateReject(L_UCHAR nResult, L_UCHAR nSource, L_UCHAR nReason);//OnReceiveAssociateReject
   L_VOID LMyDicomNet::OnReceiveAssociateRequest(LDicomAssociate *pPDU);//OnReceiveAssociateRequest
   L_VOID LMyDicomNet::OnReceiveCCancelRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID);//OnReceiveCCancelRequest
   L_VOID LMyDicomNet::OnReceiveCEchoRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass);//OnReceiveCEchoRequest
   L_VOID LMyDicomNet::OnReceiveCEchoResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus);//OnReceiveCEchoResponse
   L_VOID LMyDicomNet::OnReceiveCFindRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nPriority, LDicomDS *pDS);//OnReceiveCFindRequest
   L_VOID LMyDicomNet::OnReceiveCFindResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus, LDicomDS *pDS);//OnReceiveCFindResponse
   L_VOID LMyDicomNet::OnReceiveCGetRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nPriority, LDicomDS *pDS);//OnReceiveCGetRequest
   L_VOID LMyDicomNet::OnReceiveCGetResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus, L_UINT16 nRemaining, L_UINT16 nCompleted, L_UINT16 nFailed, L_UINT16 nWarning, LDicomDS *pDS);//OnReceiveCGetResponse
   L_VOID LMyDicomNet::OnReceiveCMoveRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nPriority, L_TCHAR *pszMoveAE, LDicomDS *pDS);//OnReceiveCMoveRequest
   L_VOID LMyDicomNet::OnReceiveCMoveResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_UINT16 nStatus, L_UINT16 nRemaining, L_UINT16 nCompleted, L_UINT16 nFailed, L_UINT16 nWarning, LDicomDS *pDS);//OnReceiveCMoveResponse
   L_VOID LMyDicomNet::OnReceiveCStoreRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nPriority, L_TCHAR *pszMoveAE, L_UINT16 nMoveMessageID, LDicomDS *pDS);//OnReceiveCStoreRequest
   L_VOID LMyDicomNet::OnReceiveCStoreResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus);//OnReceiveCStoreResponse
   L_VOID LMyDicomNet::OnReceiveData(L_UCHAR nID, LDicomDS *pCS, LDicomDS *pDS);//OnReceiveData
   L_VOID LMyDicomNet::OnReceiveNActionRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nAction, LDicomDS *pDS);//OnReceiveNActionRequest
   L_VOID LMyDicomNet::OnReceiveNActionResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, L_UINT16 nAction, LDicomDS *pDS);//OnReceiveNActionResponse
   L_VOID LMyDicomNet::OnReceiveNCreateRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, LDicomDS *pDS);//OnReceiveNCreateRequest
   L_VOID LMyDicomNet::OnReceiveNCreateResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, LDicomDS *pDS);//OnReceiveNCreateResponse
   L_VOID LMyDicomNet::OnReceiveNDeleteRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance);//OnReceiveNDeleteRequest
   L_VOID LMyDicomNet::OnReceiveNDeleteResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus);//OnReceiveNDeleteResponse
   L_VOID LMyDicomNet::OnReceiveNGetRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT32 *pnAttribute, L_UINT16 nCount);//OnReceiveNGetRequest
   L_VOID LMyDicomNet::OnReceiveNGetResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, LDicomDS *pDS);//OnReceiveNGetResponse
   L_VOID LMyDicomNet::OnReceiveNReportRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nEvent, LDicomDS *pDS);//OnReceiveNReportRequest
   L_VOID LMyDicomNet::OnReceiveNReportResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, L_UINT16 nEvent, LDicomDS *pDS);//OnReceiveNReportResponse
   L_VOID LMyDicomNet::OnReceiveNSetRequest(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, LDicomDS *pDS);
   L_VOID LMyDicomNet::OnReceiveNSetResponse(L_UCHAR nPresentationID, L_UINT16 nMessageID, L_TCHAR *pszClass, L_TCHAR *pszInstance, L_UINT16 nStatus, LDicomDS *pDS);
   L_VOID LMyDicomNet::OnReceiveReleaseRequest();
   L_VOID LMyDicomNet::OnReceiveReleaseResponse();
   L_VOID LMyDicomNet::OnReceiveUnknown(L_UCHAR nPresentationID, LDicomDS *pCS, LDicomDS *pDS);
   L_VOID LMyDicomNet::OnSecureLinkReady(L_UINT32 nError);
   L_VOID LMyDicomNet::OnSend(L_INT nError, L_UCHAR nType, L_UINT32 nBytes);
   L_INT LMyDicomNet::OnPrivateKeyPassword(L_TCHAR *pszPassword, L_INT nSize, L_INT nFlag);
   };
#endif // #ifdef LMyDicomNet
/*</struct>*/
LMyDicomNet::LMyDicomNet(L_TCHAR *pszPath, L_INT32 nMode) : LDicomNet(pszPath, nMode)
{
   //Code.........
}
LMyDicomNet::LMyDicomNet(L_TCHAR *pszPath, L_INT32 nMode, L_BOOL bReserved) : LDicomNet(pszPath, nMode, bReserved)
{
   //Code ........
}
LMyDicomNet::~LMyDicomNet() 
{
   //Code ........
}
L_INT LMyDicomNet::OnPrivateKeyPassword(L_TCHAR *pszPassword, L_INT nSize, L_INT nFlag)
{
   UNREFERENCED_PARAMETER(pszPassword);
   UNREFERENCED_PARAMETER(nSize);
   UNREFERENCED_PARAMETER(nFlag);
   return SUCCESS;
}
L_VOID LMyDicomNet::OnReceiveAssociateRequest(LDicomAssociate *pPDU)//OnReceiveAssociateRequest
{
   UNREFERENCED_PARAMETER(pPDU);
}
L_VOID   LMyDicomNet::OnConnect(L_INT nError)
{
   L_UINT lServerPort, lClientPort;
   L_TCHAR  szServerAddress[100], szClientAddress[100];
   CString strMsg;
   CString strTmp;
   
   strMsg.Format(TEXT("*** OnConnect ***\n"));
   if (nError == DICOM_SUCCESS)
   {
      GetHostInfo(szClientAddress, 100,
    &lClientPort);
      strTmp.Format(TEXT("ClientAddress[%s]\nClientPort[%d]\n"), szClientAddress, lClientPort);
      strMsg = strMsg + strTmp;
      
      GetPeerInfo(szServerAddress, 100,
    &lServerPort);
      strTmp.Format(TEXT("ServerAddress[%s]\nServerPort[%d]\n"), szServerAddress, lServerPort);
      strMsg = strMsg + strTmp;
   } 
   else
   {
      strTmp.Format(TEXT("Error[%d]\n"),nError);
      strMsg = strMsg + strTmp;
   }
   
   AfxMessageBox(strMsg);
}