i want to use the MFC CSocket class in a console application.
for learning i used CSocket in a dialog based GUI program.
everything workd fine.
now i ported the code to my console application.
first i call AFXSocketInit(), then i call the socket create
function. my program produces a assert error.
i think MFC is trying to open a window.
i debugged a bit around and found some lines like these:
1. CAsyncSocket::AttachHandle(m_hSocket, this, FALSE);
2. CSocketWnd* pWnd = new CSocketWnd;
3. if (!pWnd->CreateEx(0, AfxRegisterWndClass(0),_T("Socket Notification
Sink"),WS_OVERLAPPED, 0, 0, 0, 0, NULL, NULL))
BOOMM.
in the last line i got the assertion failure.
i think MFC is using windows messages for the Socket syncronisation.
(OnAccept,OnClose and so on)
my program is a NT service and i can't open windows.
do you know how i can use the esay handling of the CSocket class in a
console app ??
or can i use other classes to make my socket life easier ??
Regards (and sorry for my english)
Martin Otten
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr << "MFC failed to initialize!" << endl;
return 1;
}
Martin Otten wrote in message <382C4453...@do.isst.fhg.de>...
wow, you are right. That works fine.
Thank you a lot.
Best regards
Martin Otten