LDicomNet::OnAccept

#include "ltdic.h"

virtual L_VOID LDicomNet::OnAccept(nError)

L_INT nError;

/* error code */

Notifies a listening connection (SCP) that it can accept pending connection requests. This function is available in the PACS Imaging Toolkit.

Parameter

Description

nError

Error code. Refer to Return Codes.

Returns

None.

Comments

A call to this function is generated on an SCP when an SCU calls LDicomNet::Connect.

To accept a connection request, call LDicomNet::Accept.

You should always accept a connection request. Once the connection is made you can check the client and close the connection if you do not wish to maintain it. Since the connection requests are queued, if you do not accept a connection, it remains in the queue. When the next request is received, it is placed in the queue behind the first request. Calling LDicomNet::Accept at this point will connect the first request, not the second, since the first request is still in the queue.

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

L_VOID   LMyDicomNet::OnAccept(L_INT nError)
{
   L_TCHAR szClientAddress[100], szServerAddress[100];
   L_UINT lServerPort, lClientPort;
   CString strMsg;
   CString strTmp;
   LMyDicomNet *pDicomNetClient;
   L_UINT32 lClientCount;
   
   strMsg.Format(TEXT("*** OnAccept ***\n"));
   if (nError == DICOM_SUCCESS)
   {
      //Server must accept the connection attempt--can reject it later
      pDicomNetClient = new LMyDicomNet(NULL, DICOM_SECURE_NONE);
      Accept(pDicomNetClient);
      strMsg = strMsg + TEXT("Accepted\n");
      
      //display some information about the connection
      GetHostInfo(szServerAddress, 100,
    &lServerPort);
      strTmp.Format(TEXT("ServerAddress[%s]\nServerPort[%d]\n"), szServerAddress, lServerPort);
      strMsg = strMsg + strTmp;
      
      //get total client count
      lClientCount = GetClientCount();
      strTmp.Format(TEXT("ClientCount[%d]\n"), lClientCount);
      strMsg = strMsg + strTmp;
      
      //Get client information
      pDicomNetClient->GetPeerInfo(szClientAddress, 100,
    &lClientPort);
      strTmp.Format(TEXT("ClientAddress[%s]\nClientPort[%d]\n"), szClientAddress, lClientPort);
      strMsg = strMsg + strTmp;
      
   }
   else
   {
      strTmp.Format(TEXT("Error[%d]\n"),nError);
      strMsg = strMsg + strTmp;
   }
   
   
   AfxMessageBox(strMsg);
   
   //reject the connection if we do not like the address
   if (lstrcmp(szClientAddress,TEXT("207.238.49.190"))==0) 
   {  //close the connection
      CString strTmp;
      strTmp.Format(TEXT("Closing connection with client [%s]..."), szClientAddress);
      AfxMessageBox(strTmp);
      Close();
   }
}