CURLMOPT_SOCKETDATA.3 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLMOPT_SOCKETDATA 3 "3 Nov 2014" libcurl libcurl
  26. .SH NAME
  27. CURLMOPT_SOCKETDATA \- custom pointer passed to the socket callback
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_SOCKETDATA, void *pointer);
  32. .SH DESCRIPTION
  33. A data \fIpointer\fP to pass to the socket callback set with the
  34. \fICURLMOPT_SOCKETFUNCTION(3)\fP option.
  35. This pointer will not be touched by libcurl but will only be passed in to the
  36. socket callbacks's \fBclientp\fP argument.
  37. .SH DEFAULT
  38. NULL
  39. .SH PROTOCOLS
  40. All
  41. .SH EXAMPLE
  42. .nf
  43. static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
  44. {
  45. GlobalInfo *g = (GlobalInfo*) cbp;
  46. SockInfo *fdp = (SockInfo*) sockp;
  47. if(what == CURL_POLL_REMOVE) {
  48. remsock(fdp);
  49. }
  50. else {
  51. if(!fdp) {
  52. addsock(s, e, what, g);
  53. }
  54. else {
  55. setsock(fdp, s, e, what, g);
  56. }
  57. }
  58. return 0;
  59. }
  60. main()
  61. {
  62. GlobalInfo setup;
  63. /* ... use socket callback and custom pointer */
  64. curl_multi_setopt(multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
  65. curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, &setup);
  66. }
  67. .fi
  68. .SH AVAILABILITY
  69. Added in 7.15.4
  70. .SH RETURN VALUE
  71. Returns CURLM_OK.
  72. .SH "SEE ALSO"
  73. .BR CURLMOPT_SOCKETFUNCTION "(3), " curl_multi_socket_action "(3), "
  74. .BR CURLMOPT_TIMERFUNCTION "(3) "