curl_multi_assign.3 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. .\" $Id$
  2. .\"
  3. .TH curl_multi_assign 3 "9 Jul 2006" "libcurl 7.16.0" "libcurl Manual"
  4. .SH NAME
  5. curl_multi_assign \- set data to association with an internal socket
  6. .SH SYNOPSIS
  7. #include <curl/curl.h>
  8. CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd,
  9. void *sockptr);
  10. .SH DESCRIPTION
  11. This function assigns an association in the multi handle between the given
  12. socket and a private pointer of the application. This is (only) useful for
  13. \fIcurl_multi_socket(3)\fP uses.
  14. When set, the \fIsockptr\fP pointer will be passed to all future socket
  15. callbacks for the specific \fIsockfd\fP socket.
  16. If the given \fIsockfd\fP isn't already in use by libcurl, this function will
  17. return an error.
  18. libcurl only keeps one single pointer associated with a socket, so calling
  19. this function several times for the same socket will make the last set pointer
  20. get used.
  21. The idea here being that this association (socket to private pointer) is
  22. something that just about every application that uses this API will need and
  23. then libcurl can just as well do it since it already has an internal hash
  24. table lookup for this.
  25. .SH "RETURN VALUE"
  26. The standard CURLMcode for multi interface error codes.
  27. .SH "TYPICAL USAGE"
  28. In a typical application you allocate a struct or at least use some kind of
  29. semi-dynamic data for each socket that we must wait for action on when using
  30. the \fIcurl_multi_socket(3)\fP approach.
  31. When our socket-callback gets called by libcurl and we get to know about yet
  32. another socket to wait for, we can use \fIcurl_multi_assign(3)\fP to point out
  33. the particular data so that when we get updates about this same socket again,
  34. we don't have to find the struct associated with this socket by ourselves.
  35. .SH AVAILABILITY
  36. This function was added in libcurl 7.15.5, although not deemed stable yet.
  37. .SH "SEE ALSO"
  38. .BR curl_multi_setopt "(3), " curl_multi_socket "(3) "