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 15Added-in: 7.15.4 16--- 17 18# NAME 19 20curl_multi_socket - read/write available data 21 22# SYNOPSIS 23 24~~~c 25#include <curl/curl.h> 26CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t sockfd, 27 int *running_handles); 28~~~ 29 30# DESCRIPTION 31 32This function is deprecated. Do not use. See curl_multi_socket_action(3) 33instead. 34 35At return, the integer **running_handles** points to contains the number of 36still running easy handles within the multi handle. When this number reaches 37zero, all transfers are complete/done. Note that when you call 38curl_multi_socket(3) on a specific socket and the counter decreases by one, it 39DOES NOT necessarily mean that this exact socket/transfer is the one that 40completed. Use curl_multi_info_read(3) to figure out which easy handle that 41completed. 42 43The curl_multi_socket(3) functions inform the application about updates in the 44socket (file descriptor) status by doing none, one, or multiple calls to the 45socket callback function set with the CURLMOPT_SOCKETFUNCTION(3) option to 46curl_multi_setopt(3). They update the status with changes since the previous 47time the callback was called. 48 49Get the timeout time by setting the CURLMOPT_TIMERFUNCTION(3) option with 50curl_multi_setopt(3). Your application then gets called with information on 51how long to wait for socket actions at most before doing the timeout action: 52call the curl_multi_socket_action(3) function with the **sockfd** argument set 53to CURL_SOCKET_TIMEOUT. You can also use the curl_multi_timeout(3) function to 54poll the value at any given time, but for an event-based system using the 55callback is far better than relying on polling the timeout value. 56 57Usage of curl_multi_socket(3) is deprecated, whereas the function is 58equivalent to curl_multi_socket_action(3) with **ev_bitmask** set to 0. 59 60# %PROTOCOLS% 61 62# EXAMPLE 63 64~~~c 65int main(void) 66{ 67 /* the event-library gets told when there activity on the socket 'fd', 68 which we translate to a call to curl_multi_socket_action() */ 69 int running; 70 int rc; 71 int fd; 72 CURLM *multi; 73 rc = curl_multi_socket(multi, fd, &running); 74} 75~~~ 76 77# DEPRECATED 78 79curl_multi_socket(3) is deprecated, use curl_multi_socket_action(3) instead. 80 81# %AVAILABILITY% 82 83# RETURN VALUE 84 85CURLMcode type, general libcurl multi interface error code. 86 87The return code is for the whole multi stack. Problems still might have 88occurred on individual transfers even when one of these functions return OK. 89