Subj : Re: _beginthread -- how to terminate a thread from out side of it. To : comp.programming.threads From : Ian Date : Wed Aug 24 2005 09:56 pm liangbowen@hotmail.com wrote: > As i konw, the only way to to terminate a thread started by > _beginthread() is to user _endthread() (or return) inside the thread. > > > now i started a thread(TodoThread), and created a listenning socket > inside the thread. > I want to destroy the socket and kill the thread at anytime if there is > no client connect to it. How? > > > void TodoThread(PVOID pvoid){ > //creat a tcp socket > //then listen > accept(); > //..... > } > Use a non-blocking socket and use select or poll to wait for the connection. Ian. .