CWinThread::CAsyncSocket::Create issues
-
Hi, I have a derived CAsyncSocket class which is a protected member of a Derived CWinThread class There are 4 of the derived CWinThread Classes each with their own derived CAsynSocket Class I create or rather allocate storage for the derived CWinThread class on the heap via new after I create the CWinThread derived class suspended and set various members as the ipaddr Then I do a Resumethread in the CwinThread::Initinstance I do the CAsyncSocket::Create this is where the issue is while tracing the code under VS debugger the code jumps out the CWinThread::Initinstance back to my main line loop When I allocate a CAsyncSocket Class on the stack outside of the loop and do a Create everything is cool I get a return code of 1
-
Hi, I have a derived CAsyncSocket class which is a protected member of a Derived CWinThread class There are 4 of the derived CWinThread Classes each with their own derived CAsynSocket Class I create or rather allocate storage for the derived CWinThread class on the heap via new after I create the CWinThread derived class suspended and set various members as the ipaddr Then I do a Resumethread in the CwinThread::Initinstance I do the CAsyncSocket::Create this is where the issue is while tracing the code under VS debugger the code jumps out the CWinThread::Initinstance back to my main line loop When I allocate a CAsyncSocket Class on the stack outside of the loop and do a Create everything is cool I get a return code of 1
-
Hi I moved my code from the initinstance to the CWinThread constructer and it worked ? Don't know why
What was the issue? ...you never actually say what the problem was.
-
What was the issue? ...you never actually say what the problem was.
Hi I have a loop in my CWinApp::Initinstance where I create 4 Derived CWinThreads a derived CAsyncSocket class is a protected member When I step into with the debugger to the CasyncSocket::create it takes a wild which is in the CWinThread::Initinstance it takes a branch out the CWinThread::Initinstance back to the loop as if there some sort of exception I tried a try { around the code but it didn't go to the catch it just jumped out of the CWinThread::Initinstance back to the loop
for (i = 0, start\_port = 11007; i < 4; start\_port++, i++) { threadptr\[i\] = new SockCLeintThread(start\_port); if (threadptr\[i\] == NULL) AfxMessageBox((LPCTSTR)"SockClientThreadFail",NULL,MB\_ICONERROR); ret = threadptr\[i\]->CreateThread(CREATE\_SUSPENDED); if(ret == 0) errcd = GetLastError();
//
threadptr[i]->flags.is_connected = 0;
threadptr[i]->flags.busy = 0;
threadptr[i]->ResumeThread();BOOL SockCLeintThread::InitInstance
{
AfxSocketInit();
// ipaddr = "192.168.1.4";
// thisocket(myport);
ipaddr = (LPCTSTR)"10.0.0.205";if(thisocket.Create(thisocket.port,SOCK\_STREAM,(FD\_READ | FD\_WRITE | FD\_OOB | FD\_ACCEPT | FD\_CONNECT | FD\_CLOSE),ipaddr)== 0) { error\_code = thisocket.GetLastError(); } DWORD value; BOOL val, return\_code; const void \*valptr = &val; thisocket.AsyncSelect(FD\_READ | FD\_WRITE | FD\_OOB | FD\_ACCEPT | FD\_CONNECT | FD\_CLOSE); // request notifications val = 1; return\_code = thisocket.SetSockOpt(SO\_KEEPALIVE,valptr,sizeof(BOOL));// val = 1; return\_code = thisocket.SetSockOpt(SO\_OOBINLINE,valptr,sizeof(BOOL)); value = 1; return\_code = thisocket.IOCtl(FIONBIO,&value); return\_code = thisocket.IOCtl(FIONREAD,&value); return\_code = thisocket.IOCtl(SIOCATMARK,&value); sockbuffer = new TCHAR\[100\];
}
When I move this code to the SockCLientThread constructor it works