Link to home
Start Free TrialLog in
Avatar of SD_Adept
SD_Adept

asked on

threaded socket in MFC system service

I've got a problem with trying to use a CAsyncSocket in an MFC system service.  The service is coded as an EXE and currently being run in console mode (for debugging).

The problem I am having is that after I do my AfxSocketInit() I instantiate the socket as follows

   AfxSocketInit();

      CUDPSocket *m_pUDPSocket;
      m_pUDPSocket = new CUDPSocket;            //( this );
      m_pUDPSocket->Create( 2230, SOCK_DGRAM, FD_READ );
 
when I do the create I get the following assert/message Dialog

Microsoft Visual C++ Debug Libary
Debug Assertion Failed

Program myprogram.exe
File: afxwin1.inl
Line 19

press retry etc....

now, line 19 is the middle line of the following code

_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
{
LINE 19-> ASSERT(afxCurrentInstanceHandle != NULL);
      return afxCurrentInstanceHandle;
}


SO.  my question is obvious.  Whats going wrong here, why can't I create my socket?

any help would be appreciated.

thanks
Avatar of SD_Adept
SD_Adept

ASKER

Edited text of question.
set some breakpoints and debug your application ...
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
chensu, excellent, that worked perfectly.  thanks!


[Note to nil_dib for his comment.... geee, ya think?]