cURL / Mailing Lists / curl-library / Single Mail

curl-library

Query regarding CURLOPT_OPENSOCKETFUNCTION

From: Lijo Antony <lta_at_one.com>
Date: Sun, 25 Mar 2012 14:56:18 +0400

Hi,

I have observed that when opensocket_callback returns CURL_SOCKET_BAD,
libcurl returns CURLE_FAILED_INIT instead of CURLE_COULDNT_CONNECT. This
is incorrect as per the documentation at
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTOPENSOCKETFUNCTION.
Is this a bug?

This can be easily reproduced by changing the return value of opensocket
function to CURL_SOCKET_BAD, in the example program externalsocket.c.
When I executed with this change I got the below output,

$./a.out
* About to connect() to 99.99.99.99 port 9999 (#0)
* Closing connection #0
* Failed initialization
libcurl error: 2

and my change was,

--- externalsocket.c.orig 2012-03-25 14:48:53.505770709 +0400
+++ externalsocket.c 2012-03-25 14:30:25.017793554 +0400
@@ -60,7 +60,8 @@
    curl_socket_t sockfd = *(curl_socket_t *)clientp;
    /* the actual externally set socket is passed in via the OPENSOCKETDATA
       option */
- return sockfd;
+ /*return sockfd;*/
+ return CURL_SOCKET_BAD;
  }

-lijo

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-25