Hello!
I've a multiwindows multithreaded program.
Into a thread, I open socket to receive data with infinite loop. This thread was created by : MyThread = CreateThread(NULL, 0, MySocketsFunction, &MyDatas, 0, NULL);
When user wants stop listening, he clicks on STOP button.
Which makes a : TerminateThread(MyThread,0);
The problem is my thread was listening (recvfrom) on port when it was stopped by TerminateThread.
But as function is suddently stopped, socket is not closed with closesocket(IdMonSocket); because this calling is at the end of the function
So, I can see with netstat -a, that my port is already opened, but thread was terminated.
How can I make to close socket when I terminate thread ?
Thank You!



LinkBack URL
About LinkBacks


