Archived

This topic is now archived and is closed to further replies.

MFC CAsyncSocket create problems

This topic is 5588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I''m deriving a socket class from the MFC CAsyncSocket class, when I call the CAsyncSocket''s create function the create fails. I have the same code in a different program and the socket create works just fine. Does anyone have any idea on what the problem might be? Thanks

Share this post


Link to post
Share on other sites
quote:
Original post by Cityhunter
Hi
I''m deriving a socket class from the MFC CAsyncSocket class, when I call the CAsyncSocket''s create function the create fails.
I have the same code in a different program and the socket create works just fine.
Does anyone have any idea on what the problem might be?
Thanks


1) In StdAfx.h add string:
#include <afxsock.h>

2) In begin function: .....App::InitInstance()
Add:
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}

It''s help.
And offten use, it''s real help you know error

try {
...
code
...
} catch(CException* e) {

TCHAR szCause[255];
CString strFormatted;

e->GetErrorMessage(szCause, 255);

strFormatted = _T("Error exception: \n");
strFormatted += szCause;

AfxMessageBox(strFormatted);
return NULL;
}

Share this post


Link to post
Share on other sites