Accept Example for C++ 6.0 and later

void CDicomNetSink::OnNetAccept (long nStatus) 
{
   CString cStr;
   CString strTmp;
   long hClient;
   long lClients;
   
   cStr.Format("*** NetAccept Event ***\n nStatus[%d]\n", nStatus);
   
   //accept the connection attempt
   m_pDlg->m_pLEADDicomNet->Accept();
   cStr = cStr + "Accepted\n";
   
   //display some information about the connection
   _bstr_t sHostAddress = m_pDlg->m_pLEADDicomNet->GetHostAddress(m_pDlg->m_pLEADDicomNet->GethNet());
   cStr = cStr + "Host: " + (char *)sHostAddress + "\n";
   
   //get the latest client
   lClients = m_pDlg->m_pLEADDicomNet->GetClientCount(m_pDlg->m_pLEADDicomNet->GethNet());
   hClient = m_pDlg->m_pLEADDicomNet->GetClient(m_pDlg->m_pLEADDicomNet->GethNet(), lClients - 1);
   
   strTmp.Format("ClientCount[%d]\nLatest Client[%x]\n", lClients, hClient);
   cStr = cStr + strTmp;
   
   _bstr_t sPeerAddress = m_pDlg->m_pLEADDicomNet->GetPeerAddress(hClient);
   long lPeerPort = m_pDlg->m_pLEADDicomNet->GetPeerPort(hClient);
   
   strTmp.Format("PeerAddress[%s]\nPeerPort[%d]\n", (char*)sPeerAddress, lPeerPort);
   cStr = cStr + strTmp;
   
   AfxMessageBox(cStr);
   
   //reject the connection if we do not like the address
   if ((char *)m_pDlg->m_pLEADDicomNet->GetPeerAddress (hClient) == "207.238.49.199") 
      //close the connection
      m_pDlg->m_pLEADDicomNet->Close(hClient);
}