CURLOPT_CLOSESOCKETDATA.3 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from CURLOPT_CLOSESOCKETDATA.md
  2. .TH CURLOPT_CLOSESOCKETDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_CLOSESOCKETDATA \- pointer passed to the socket close callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CLOSESOCKETDATA,
  9. void *pointer);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a \fIpointer\fP that remains untouched by libcurl and passed as the first
  13. argument in the closesocket callback set with
  14. \fICURLOPT_CLOSESOCKETFUNCTION(3)\fP.
  15. .SH DEFAULT
  16. NULL
  17. .SH PROTOCOLS
  18. This functionality affects all supported protocols
  19. .SH EXAMPLE
  20. .nf
  21. struct priv {
  22. void *custom;
  23. };
  24. static int closesocket(void *clientp, curl_socket_t item)
  25. {
  26. struct priv *my = clientp;
  27. printf("our ptr: %p\\n", my->custom);
  28. printf("libcurl wants to close %d now\\n", (int)item);
  29. return 0;
  30. }
  31. int main(void)
  32. {
  33. struct priv myown;
  34. CURL *curl = curl_easy_init();
  35. /* call this function to close sockets */
  36. curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket);
  37. curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &myown);
  38. curl_easy_perform(curl);
  39. curl_easy_cleanup(curl);
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.21.7
  44. .SH RETURN VALUE
  45. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  46. .SH SEE ALSO
  47. .BR CURLOPT_CLOSESOCKETFUNCTION (3),
  48. .BR CURLOPT_OPENSOCKETFUNCTION (3)