diff options
Diffstat (limited to 'lib/getinfo.c')
-rw-r--r-- | lib/getinfo.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/getinfo.c b/lib/getinfo.c index 910f520ed..90ea45424 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -334,6 +334,31 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info, return CURLE_OK; } +static CURLcode getinfo_socket(struct SessionHandle *data, CURLINFO info, + curl_socket_t *param_socketp) +{ + curl_socket_t sockfd; + + switch(info) { + case CURLINFO_ACTIVESOCKET: + sockfd = Curl_getconnectinfo(data, NULL); + + /* note: this is not a good conversion for systems with 64 bit sockets and + 32 bit longs */ + if(sockfd != CURL_SOCKET_BAD) + *param_socketp = sockfd; + else + /* this interface is documented to return -1 in case of badness, which + may not be the same as the CURL_SOCKET_BAD value */ + *param_socketp = -1; + break; + default: + return CURLE_BAD_FUNCTION_ARGUMENT; + } + + return CURLE_OK; +} + CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) { va_list arg; @@ -341,6 +366,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) double *param_doublep = NULL; char **param_charp = NULL; struct curl_slist **param_slistp = NULL; + curl_socket_t *param_socketp = NULL; int type; /* default return code is to error out! */ CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT; @@ -372,6 +398,11 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) if(param_slistp) result = getinfo_slist(data, info, param_slistp); break; + case CURLINFO_SOCKET: + param_socketp = va_arg(arg, curl_socket_t *); + if(param_socketp) + result = getinfo_socket(data, info, param_socketp); + break; default: break; } |