killing a separate thread having a socket

Posted by user311906 on Stack Overflow See other posts from Stack Overflow or by user311906
Published on 2010-04-13T14:18:41Z Indexed on 2010/04/13 14:42 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

Hi All

I have a separate thread ListenerThread having a socket listening to info broadcasted by some remote server. This is created at the constructor of one class I need to develop.

Because of requirements, once the separate thread is started I need to avoid any blocking function on the main thread. Once it comes to the point of calling the destructor of my class I cannot perform a join on the listener thread so the only thing I can do is to KILL it.

My questions are:

  1. what happens to the network resoruces allocated by the function passed to the thead? Is the socket closed properly or there might be something pending? ( most worried about this )

  2. is this procedure fast enough i.e. is the thread killed so that interrupt immediately ?

  3. I am working with Linux ...what command or what can I check to ensure that there is no networking resource left pending or that something went wrong for the Operating system

I thank you very much for your help

Regards MNSTN

NOTE: I am using boost::thread in C++

© Stack Overflow or respective owner

Related posts about threading

Related posts about networking