curl-library
[PATCH] new connect status callback
Date: Tue, 2 Feb 2010 12:13:42 -0500
Hi All,
I've attached a small patch for curl-7.9.17 which is based on the
connect-progress-2.patch created by Dan Stenberg that is posted here
http://curl.haxx.se/mail/lib-2010-01/0077.html
Basically instead of invoking the progress callback during the connect
process and sending 0 values for all the speed arguments, I've created
a couple new curl options called CURLOPT_CONNECTINGFUNCTION, and
CURLOPT_CONNECTINGDATA. Using these will allow you to delegate
progress info and connect status info separately in your applications.
The first curl option takes a pointer to a curl_connecting_callback defined as:
typedef int (*curl_connecting_callback)(CURL *curl, enum
curl_connstat st, void *ptr);
The function gets invoked after DNS resolution when curl tries to
connect to an IP address. It gets called approximately once per second
until the connection succeeds or fails. Returning a non-zero value
from this callback will cancel the operation. The possible connection
status values are defined as:
enum curl_connstat {
CURL_CONN_STILL, /* still connecting */
CURL_CONN_OK, /* successfully connected */
CURL_CONN_ERROR, /* failed connecting */
CURL_CONN_LAST /* not for use, marker for last-in-list */
};
The second curl option is a custom pointer that will be the third
argument passed into the callback.
I haven't tested this extensively, but so far seems to work pretty
well. If anyone has any suggestions for how to make this better I
would love to hear it. So far the patch has been quite useful in one
of my current applications; I hope some of you will find it useful as
well.
-- nick jensen
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
- application/octet-stream attachment: curl-connect-status.patch