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