1curl_multi_assign(3)            libcurl Manual            curl_multi_assign(3)
2
3
4

NAME

6       curl_multi_assign - set data to associate with an internal socket
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd,
12                                   void *sockptr);
13

DESCRIPTION

15       This  function  creates  an association in the multi handle between the
16       given socket and a private pointer of the application. This is designed
17       for curl_multi_socket_action(3) uses.
18
19       When set, the sockptr pointer will be passed to all future socket call‐
20       backs for the specific sockfd socket.
21
22       If the given sockfd isn't already in use by libcurl, this function will
23       return an error.
24
25       libcurl  only  keeps  one  single  pointer associated with a socket, so
26       calling this function several times for the same socket will  make  the
27       last set pointer get used.
28
29       The  idea  here being that this association (socket to private pointer)
30       is something that just about every application that uses this API  will
31       need  and  then  libcurl can just as well do it since it already has an
32       internal hash table lookup for this.
33

RETURN VALUE

35       The standard CURLMcode for multi interface error codes.
36

TYPICAL USAGE

38       In a typical application you allocate a struct or  at  least  use  some
39       kind  of semi-dynamic data for each socket that we must wait for action
40       on when using the curl_multi_socket_action(3) approach.
41
42       When our socket-callback gets called by libcurl  and  we  get  to  know
43       about  yet  another socket to wait for, we can use curl_multi_assign(3)
44       to point out the particular data so that when we get updates about this
45       same  socket  again,  we  don't have to find the struct associated with
46       this socket by ourselves.
47

AVAILABILITY

49       This function was added in libcurl 7.15.5.
50

SEE ALSO

52       curl_multi_setopt(3), curl_multi_socket_action(3)
53
54
55
56libcurl 7.66.0                 February 03, 2016          curl_multi_assign(3)
Impressum