curl_multi_assign.3 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2014, 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.haxx.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. .\" **************************************************************************
  22. .TH curl_multi_assign 3 "9 Jul 2006" "libcurl 7.16.0" "libcurl Manual"
  23. .SH NAME
  24. curl_multi_assign \- set data to associate with an internal socket
  25. .SH SYNOPSIS
  26. #include <curl/curl.h>
  27. CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd,
  28. void *sockptr);
  29. .SH DESCRIPTION
  30. This function creates an association in the multi handle between the given
  31. socket and a private pointer of the application. This is designed for
  32. \fIcurl_multi_socket_action(3)\fP uses.
  33. When set, the \fIsockptr\fP pointer will be passed to all future socket
  34. callbacks for the specific \fIsockfd\fP socket.
  35. If the given \fIsockfd\fP isn't already in use by libcurl, this function will
  36. return an error.
  37. libcurl only keeps one single pointer associated with a socket, so calling
  38. this function several times for the same socket will make the last set pointer
  39. get used.
  40. The idea here being that this association (socket to private pointer) is
  41. something that just about every application that uses this API will need and
  42. then libcurl can just as well do it since it already has an internal hash
  43. table lookup for this.
  44. .SH "RETURN VALUE"
  45. The standard CURLMcode for multi interface error codes.
  46. .SH "TYPICAL USAGE"
  47. In a typical application you allocate a struct or at least use some kind of
  48. semi-dynamic data for each socket that we must wait for action on when using
  49. the \fIcurl_multi_socket_action(3)\fP approach.
  50. When our socket-callback gets called by libcurl and we get to know about yet
  51. another socket to wait for, we can use \fIcurl_multi_assign(3)\fP to point out
  52. the particular data so that when we get updates about this same socket again,
  53. we don't have to find the struct associated with this socket by ourselves.
  54. .SH AVAILABILITY
  55. This function was added in libcurl 7.15.5.
  56. .SH "SEE ALSO"
  57. .BR curl_multi_setopt "(3), " curl_multi_socket_action "(3) "