aegressy
asked on
CAsyncSocket - OnAccept method NOT CALLED
If anybody knows, what could cause that
the OnAccept method of the CAsyncSocket class is not called,
please help me!
My code is as follows:
/************************* ********** ********** *********/
CMySocket::CMySocket()
{
if ( !Create( 80, SOCK_STREAM, FD_ACCEPT ) ) throw CMyException( 1, GetMyLastError() );
if ( !Listen() ) throw CMyException( 2, GetMyLastError() );
}
CMySocket::~CMySocket()
{
Close();
}
#if 0
BEGIN_MESSAGE_MAP(CMySocke t, CAsyncSocket)
//{{AFX_MSG_MAP(CMySocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
void CMySocket::OnAccept( int nErrorCode )
{
// HERE IS A BREAKPOINT
AfxMessageBox( "REQUEST" );
CAsyncSocket::OnAccept(nEr rorCode);
}
char *CMySocket::GetMyLastError ()
{
switch ( GetLastError() )
{
case WSAEFAULT: return "WSAEFAULT";
case WSANOTINITIALISED: return "WSANOTINITIALISED";
case WSAENETDOWN: return "WSAENETDOWN";
case WSAEINPROGRESS: return "WSAEINPROGRESS";
default: return "???";
}
}
/************************* ********** ********** *********/
Note: When I try to connect to the socket from Internet Explorer (watching the comunication on TCPView - something like dynamically refreshing netstat), the socket is listening and then connection is established, but - is I've told - the OnAccept method is never called :-(
Why???
Regards
Aegressy
the OnAccept method of the CAsyncSocket class is not called,
please help me!
My code is as follows:
/*************************
CMySocket::CMySocket()
{
if ( !Create( 80, SOCK_STREAM, FD_ACCEPT ) ) throw CMyException( 1, GetMyLastError() );
if ( !Listen() ) throw CMyException( 2, GetMyLastError() );
}
CMySocket::~CMySocket()
{
Close();
}
#if 0
BEGIN_MESSAGE_MAP(CMySocke
//{{AFX_MSG_MAP(CMySocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
void CMySocket::OnAccept( int nErrorCode )
{
// HERE IS A BREAKPOINT
AfxMessageBox( "REQUEST" );
CAsyncSocket::OnAccept(nEr
}
char *CMySocket::GetMyLastError
{
switch ( GetLastError() )
{
case WSAEFAULT: return "WSAEFAULT";
case WSANOTINITIALISED: return "WSANOTINITIALISED";
case WSAENETDOWN: return "WSAENETDOWN";
case WSAEINPROGRESS: return "WSAEINPROGRESS";
default: return "???";
}
}
/*************************
Note: When I try to connect to the socket from Internet Explorer (watching the comunication on TCPView - something like dynamically refreshing netstat), the socket is listening and then connection is established, but - is I've told - the OnAccept method is never called :-(
Why???
Regards
Aegressy
ASKER
ShaunWilde,
thanks for your response, yes, I've done the AfxSocketInit(), I can send you my code if you want - or if you tried this, would you be so kind and send me your program? (If so, my mail address is: aegressy@yahoo.com)
A very similar code works fine in HTTPSVR sample from the MSDN lib. on the same machine, compiled in the same environment... And after two days I simply don't know what is wrong with this.
Thanks a lot!
Aegressy
thanks for your response, yes, I've done the AfxSocketInit(), I can send you my code if you want - or if you tried this, would you be so kind and send me your program? (If so, my mail address is: aegressy@yahoo.com)
A very similar code works fine in HTTPSVR sample from the MSDN lib. on the same machine, compiled in the same environment... And after two days I simply don't know what is wrong with this.
Thanks a lot!
Aegressy
please send your code shaun_wilde@hotmail.com
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot!
You are absolutely totally right :-)
I didn't want to create a GUI interface for this applicatoin and I didn't know, that Console (!) Win32 applications don't have their message pumps. (I thought that one is attached to the window, that the process runs in but I now realize, that this is a nonsence...)
I would like to ask you, if there is another way how to add a message pump and not have to loop in the main function?
Thank you once more.
Regards
Aegressy
You are absolutely totally right :-)
I didn't want to create a GUI interface for this applicatoin and I didn't know, that Console (!) Win32 applications don't have their message pumps. (I thought that one is attached to the window, that the process runs in but I now realize, that this is a nonsence...)
I would like to ask you, if there is another way how to add a message pump and not have to loop in the main function?
Thank you once more.
Regards
Aegressy
you can always spawn it off in it its own thread and control that from the main thread
you can create a GUI-less MFC app by having a hidden main window
an ATL exe server (or service) can have MFC support (there are MS-KB articles on how to do this) and no GUI - if you want to make one from the project wizard
you can create a GUI-less MFC app by having a hidden main window
an ATL exe server (or service) can have MFC support (there are MS-KB articles on how to do this) and no GUI - if you want to make one from the project wizard
ASKER
I've nothing more to say, than: thank you!
You also might have had better response if you posted this to the MFC forum