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. Use curl_multi_socket_action(3) instead with 33**ev_bitmask** set to 0. 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 57# %PROTOCOLS% 58 59# EXAMPLE 60 61~~~c 62int main(void) 63{ 64 /* the event-library gets told when there activity on the socket 'fd', 65 which we translate to a call to curl_multi_socket_action() */ 66 int running; 67 int rc; 68 int fd; 69 CURLM *multi; 70 rc = curl_multi_socket(multi, fd, &running); 71} 72~~~ 73 74# DEPRECATED 75 76curl_multi_socket(3) is deprecated, use curl_multi_socket_action(3) instead. 77 78# %AVAILABILITY% 79 80# RETURN VALUE 81 82CURLMcode type, general libcurl multi interface error code. 83 84The return code is for the whole multi stack. Problems still might have 85occurred on individual transfers even when one of these functions return OK. 86