1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_multi_socket 5Section: 3 6Source: libcurl 7See-also: 8 - curl_multi_cleanup (3) 9 - curl_multi_fdset (3) 10 - curl_multi_info_read (3) 11 - curl_multi_init (3) 12 - the hiperfifo.c example 13Protocol: 14 - All 15--- 16 17# NAME 18 19curl_multi_socket - reads/writes available data 20 21# SYNOPSIS 22 23~~~c 24#include <curl/curl.h> 25CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t sockfd, 26 int *running_handles); 27 28CURLMcode curl_multi_socket_all(CURLM *multi_handle, 29 int *running_handles); 30~~~ 31 32# DESCRIPTION 33 34These functions are deprecated. Do not use. See 35curl_multi_socket_action(3) instead. 36 37At return, the integer **running_handles** points to contains the number of 38still running easy handles within the multi handle. When this number reaches 39zero, all transfers are complete/done. Note that when you call 40curl_multi_socket_action(3) on a specific socket and the counter 41decreases by one, it DOES NOT necessarily mean that this exact socket/transfer 42is the one that completed. Use curl_multi_info_read(3) to figure out 43which easy handle that completed. 44 45The curl_multi_socket_action(3) functions inform the application about 46updates in the socket (file descriptor) status by doing none, one, or multiple 47calls to the socket callback function set with the 48CURLMOPT_SOCKETFUNCTION(3) option to curl_multi_setopt(3). They 49update the status with changes since the previous time the callback was 50called. 51 52Get the timeout time by setting the CURLMOPT_TIMERFUNCTION(3) option 53with curl_multi_setopt(3). Your application then gets called with 54information on how long to wait for socket actions at most before doing the 55timeout action: call the curl_multi_socket_action(3) function with the 56**sockfd** argument set to CURL_SOCKET_TIMEOUT. You can also use the 57curl_multi_timeout(3) function to poll the value at any given time, but 58for an event-based system using the callback is far better than relying on 59polling the timeout value. 60 61Usage of curl_multi_socket(3) is deprecated, whereas the function is 62equivalent to curl_multi_socket_action(3) with **ev_bitmask** set to 630. 64 65Force libcurl to (re-)check all its internal sockets and transfers instead of 66just a single one by calling curl_multi_socket_all(3). Note that there 67should not be any reason to use this function. 68 69# EXAMPLE 70 71~~~c 72int main(void) 73{ 74 /* the event-library gets told when there activity on the socket 'fd', 75 which we translate to a call to curl_multi_socket_action() */ 76 int running; 77 int rc; 78 int fd; 79 CURLM *multi; 80 rc = curl_multi_socket(multi, fd, &running); 81} 82~~~ 83 84# AVAILABILITY 85 86This function was added in libcurl 7.15.4, and is deemed stable since 877.16.0. 88 89curl_multi_socket(3) is deprecated, use 90curl_multi_socket_action(3) instead! 91 92# RETURN VALUE 93 94CURLMcode type, general libcurl multi interface error code. 95 96The return code is for the whole multi stack. Problems still might have 97occurred on individual transfers even when one of these functions return OK. 98