Solved

Accept() give me an assertion fail

Posted on 1998-10-22
1
230 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
1 Comment
 

Accepted Solution

by:
lsean earned 60 total points
Comment Utility
Don't call Creae() and SetSockOpt() for the object pointed by m_Connection.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now