?
Solved

Accept() give me an assertion fail

Posted on 1998-10-22
1
Medium Priority
?
241 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:kharandir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
lsean earned 120 total points
ID: 1323689
Don't call Creae() and SetSockOpt() for the object pointed by m_Connection.
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question