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