How to disconnect a TCP connection immediately?
Posted on 2003-03-10
Hi all, I'm writing a multithread web crawler for downloading images from the web. Each thread do the same thing: Connect to a web site, seek images and download them. And certainly it'll block when connecting to the remote server since I use block TCP mothed in each thread. So the problem comes: My program allows users to cancel downloading. It's really a headache when the thread is blocking since I can not notify that thread to end its work when it's downling or trying to build a connection to the remote server. How can I close all threads when users' trying to cancel downloading? Should I kill the thread in block? That's is the last choice if no other good solution since kill a thread will cause many problems, such as memory leak. Any one gives me a piece of hint? Thanks in advance.