cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [Fwd: canceling a load in progress]

From: Steve Dekorte <steve_at_dekorte.com>
Date: Thu, 25 Oct 2001 19:38:38 -0700

Daniel Stenberg wrote:
> Dekorte wrote:
>> curl_select_init(select_handle);
> Shouldn't it return the handle?

Oops, that's right.

>> curl_select_remove_handle(select_handle, curl_handle)
>
> Seems easy enough before the curl_select_perform() call, it might get
> tricky
> if there's a transfer in progress already...

curl_select_perform() isn't blocking, so it shouldn't be a problem.

Here's how it might work:

In curl_select_perform(), put your sockets into a readset and call
something like:

select(FD_SETSIZE, readset, 0, 0, timeout)

then loop over them and check if each has io:

if fd_isset(curl_handle.socket, readset)
   curl_handle_listen(curl_handle, readsize)

in curl_handle_listen(curl_handle) you call:

recv(curl_handle.socket, buffer, 0)

where the buffer size is the "readsize". If this socket was set to be
non-blocking when opened, it should grab as much as that amount of
waiting data and return immediately.

So curl_select_perform(select_handle) is called as part of the app's run
loop - every 1/x of a second, let's say. You call it, it finds which
handles have waiting data and tells them to read it and returns
immediately. When one curl_handle is done(or wants to send progress
data) it calls a callback.

Steve
Received on 2001-10-26