Link to home
Start Free TrialLog in
Avatar of kharandir
kharandir

asked on

Accept() give me an assertion fail

Hi,
I made two programs using the CSocket. When the server execute the Accept(), I have an assertion fail. If I ignore it, the communication works anyway but it's annoying. Here is the code

void CSockSvr::OnAccept(int nErrorCode)
{
      BOOL      Option = TRUE ;
      CString s ;

      if (m_Connection != NULL)
      {
            m_Connection->ShutDown(both) ;
            m_Connection->Close() ;
            delete m_Connection ;
      }
      m_Connection = new CSockCon ;
      m_Connection->Create() ;
      m_Connection->SetSockOpt(SO_REUSEADDR,&Option,sizeof(BOOL),SOL_SOCKET) ;

      if(!m_Server->Accept(*m_Connection))         // ASSERTION FAIL
      {
            s.Format("Error accepting the communication (%d).",GetLastError());
            AfxMessageBox(s);
      }
      else  
      {
            TRACE("Communication accepted\n") ;
      }
      
      //CSocket::OnAccept(nErrorCode);
}

Can someone help me ?
Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of plaroche
plaroche

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial