Solved

Accept() give me an assertion fail

Posted on 1998-10-22
1
232 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
ID: 1323689
Don't call Creae() and SetSockOpt() for the object pointed by m_Connection.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

22 Experts available now in Live!

Get 1:1 Help Now