Re: CAsyncSocket Close()
On 13 Okt., 20:39, Joseph M. Newcomer <newco...@flounder.com> wrote:
It has been such a long time since I wrote the code, I no longer recall, =
but killing the
thread is not going to close the socket unless the handler for UWM_TERM_T=
HREAD has
explicit code to close the socket. So see if it does. If it doesn't=
, you will have to
add it.
joe
I`ve installed the handler for the UWM_TERM_THREAD message - and the
socket will be closed. But if I allocate some heap space in the socket
class, this space won`t be deleted if the UWM_TERM_THREAD message
arrived.
I`m not sure if I really need to install CSingleLock.... Maybe it`s
quite simple to check the return value of the PostThreadMessage to
this socket class, and if the socket is no longer available the return
value is not zero -> so I can delete the heap space...
typedef std::auto_ptr< std::map<CString, CString> > PData;
HttpConnThread::SendMsgToMainthread()
{
PData pdata(new (std::map<CString, CString>));
wnd->PostDataToMainThread(pData);
}
------ socket thread will be deleted -----
After that:
void Mainthread::Send()
{
if(PostThreadMessage(threadid, UWM_SEND_TO_SOC, data, 0))
delete data;
}
best regards
Hans