1curl_multi_assign(3) libcurl Manual curl_multi_assign(3)
2
3
4
6 curl_multi_assign - set data to associated with an internal socket
7
9 #include <curl/curl.h>
10
11 CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd,
12 void *sockptr);
13
15 This function assigns an association in the multi handle between the
16 given socket and a private pointer of the application. This is (only)
17 useful for curl_multi_socket(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
35 The standard CURLMcode for multi interface error codes.
36
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(3) approach.
41
42 When our socket-callback get called by libcurl and we get to know about
43 yet another socket to wait for, we can use curl_multi_assign(3) to
44 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
49 This function was added in libcurl 7.15.5, although not deemed stable
50 yet.
51
53 curl_multi_setopt(3), curl_multi_socket(3)
54
55
56
57libcurl 7.16.0 9 Jul 2006 curl_multi_assign(3)