cURL / Mailing Lists / curl-library / Single Mail


Re: Windows people -- help needed!

From: Daniel Stenberg <>
Date: Tue, 28 Jan 2003 18:45:02 +0100 (CET)

On Tue, 28 Jan 2003, Chris Russell wrote:

Thanks a lot for your knowledgeable input!

> The gethostbyname function returns a pointer to a HOSTENT structure-a
> structure allocated by Windows Sockets. The HOSTENT structure contains the
> results of a successful search for the host specified in the name
> parameter.

We already have the functionality in libcurl that clones a hostent structure,
and it is proven to work. (We use this to allow windows-application that use
libcurl to pass libcurl easy-handles between threads.)

> the win32 api call gethostbyname could potentially be used to check the
> health of the network connection prior to opening a socket.

I don't see the purpose for the timeout quite like that. I see the main
purpose of a gethostbyname-timeout to offer the application the ability to
control how much time to spend. Other platforms already support this thanks
to the use of signals.

> The gethostbyname function cannot resolve IP address strings passed to it.

We never do that in libcurl, we detect and handle IP addresses differently.

> My suggestion would be to internally spawn a worker thread to make the
> gethostbyname call. All the worker thread does is make the gethostbyname
> call - we don't even really care about the result. The main thread then
> blocks using WaitForSingleObject passing in the thread handle as the
> synchronization object and a non-infinite timeout. Should the main thread
> fall out of wait due to a timeout we know the interface is hosed. So as not
> to screw anything up, should the timeout occur, we just leave the worker
> out hanging in the ether until the process is terminated (thus cleaning up
> any structures allocated by windows sockets), and killing the worker.

But in case of a successful lookup, it would need to pass the data between
the threads somehow, possibly by using the current struct-clone function?

Also, leaving the worker thread hanging like seems like a bad idea if we
repeatedly invoke fetches that are aborted without the application ever
terminating, as then we'll get more and more zombies lying around...

 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
Received on 2003-01-28