curl-library
Re: How to stop TCP connections immediately?
Date: Tue, 11 Mar 2003 18:19:20 +0100 (CET)
On Tue, 11 Mar 2003, Oakes King wrote:
> 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.
There is no (good) way to do that.
My advice is to fire up a new thread to take care of the new job and let the
old one finish its business and when you get control back you close it down
by the rules.
-- Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs. ------------------------------------------------------- This SF.net email is sponsored by:Crypto Challenge is now open! Get cracking and register here for some mind boggling fun and the chance of winning an Apple iPod: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031enReceived on 2003-03-11