Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Every time I try to debug the project in which I have written the Accept function I get a ASSERT leading to sockcore.cpp.
I am not able to understand what should I do next...
Can anyone please suggest what should I change in the code....

What I have tried:

**********ASSERT*********************
Debug Assertion Failed!
d:\agent\_work\3\src\vctools\VC7Libs\Ship\ATLMFC\SrcMFC\sockcorre.cpp
Line:183

For information on how your program can cause assertion failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
***************************************


the accept function I have tried..
void CFileDlg::OnAccept()
{
BOOL bRet = m_sListener.Accept(m_sConnected );
if (bRet != TRUE)
{
uErr = GetLastError();
wsprintf(szError, L"Accept failed: %d", uErr);
AfxMessageBox(szError);
}
else {

CSingleLock singleLock(&m_critsec, TRUE);
m_sharedData.bConnectClient = true;

}
Posted
Updated 18-Jul-19 20:30pm
Comments
Richard MacCutchan 18-Jul-19 8:15am    
You need to tell us which function call gives the ASSERT, and what value it is complaining about. Also when a normal error occurs, what GetLastError returns. Please remember we cannot see what happens when you run your code, you need to provide all the details.
Member 14499788 18-Jul-19 8:27am    
GetLast returns zero error, if we click on repeat in the ASSERT file then it leads from main project to sockcore.cpp

BOOL CAsyncSocket::Accept(CAsyncSocket& rConnectedSocket,
SOCKADDR* lpSockAddr, int* lpSockAddrLen)
{
It points over her----->ASSERT(rConnectedSocket.m_hSocket == INVALID_SOCKET);
ASSERT(CAsyncSocket::FromHandle(INVALID_SOCKET) == NULL);

CAsyncSocket::AttachHandle(INVALID_SOCKET, &rConnectedSocket);
if (CAsyncSocket::FromHandle(INVALID_SOCKET) == NULL)
{
// AttachHandle Call has failed
return FALSE;
}

SOCKET hTemp = accept(m_hSocket, lpSockAddr, lpSockAddrLen);

Richard MacCutchan 18-Jul-19 9:05am    
The assert seems to imply that your socket is invalid. So you must be doing something earlier in the code that is failing. The only way to trace these problems is by debugging step by step and checking every value as you go.
Member 14499788 18-Jul-19 9:15am    
okay thankyou! I will try.

1 solution

Finally I got the answer, I mistakenly created a Create() and Connect function for the socket accepting connection too.
Thankyour Richard for your suggestions!!

Cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900