curl_multi_socket.3 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. .\" generated by cd2nroff 0.1 from curl_multi_socket.md
  2. .TH curl_multi_socket 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_multi_socket \- read/write available data
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t sockfd,
  9. int *running_handles);
  10. .fi
  11. .SH DESCRIPTION
  12. This function is deprecated. Do not use. See \fIcurl_multi_socket_action(3)\fP
  13. instead.
  14. At return, the integer \fBrunning_handles\fP points to contains the number of
  15. still running easy handles within the multi handle. When this number reaches
  16. zero, all transfers are complete/done. Note that when you call
  17. \fIcurl_multi_socket(3)\fP on a specific socket and the counter decreases by one, it
  18. DOES NOT necessarily mean that this exact socket/transfer is the one that
  19. completed. Use \fIcurl_multi_info_read(3)\fP to figure out which easy handle that
  20. completed.
  21. The \fIcurl_multi_socket(3)\fP functions inform the application about updates in the
  22. socket (file descriptor) status by doing none, one, or multiple calls to the
  23. socket callback function set with the \fICURLMOPT_SOCKETFUNCTION(3)\fP option to
  24. \fIcurl_multi_setopt(3)\fP. They update the status with changes since the previous
  25. time the callback was called.
  26. Get the timeout time by setting the \fICURLMOPT_TIMERFUNCTION(3)\fP option with
  27. \fIcurl_multi_setopt(3)\fP. Your application then gets called with information on
  28. how long to wait for socket actions at most before doing the timeout action:
  29. call the \fIcurl_multi_socket_action(3)\fP function with the \fBsockfd\fP argument set
  30. to CURL_SOCKET_TIMEOUT. You can also use the \fIcurl_multi_timeout(3)\fP function to
  31. poll the value at any given time, but for an event\-based system using the
  32. callback is far better than relying on polling the timeout value.
  33. Usage of \fIcurl_multi_socket(3)\fP is deprecated, whereas the function is
  34. equivalent to \fIcurl_multi_socket_action(3)\fP with \fBev_bitmask\fP set to 0.
  35. .SH PROTOCOLS
  36. This functionality affects all supported protocols
  37. .SH EXAMPLE
  38. .nf
  39. int main(void)
  40. {
  41. /* the event-library gets told when there activity on the socket 'fd',
  42. which we translate to a call to curl_multi_socket_action() */
  43. int running;
  44. int rc;
  45. int fd;
  46. CURLM *multi;
  47. rc = curl_multi_socket(multi, fd, &running);
  48. }
  49. .fi
  50. .SH DEPRECATED
  51. \fIcurl_multi_socket(3)\fP is deprecated, use \fIcurl_multi_socket_action(3)\fP instead!
  52. .SH AVAILABILITY
  53. Added in curl 7.15.4
  54. .SH RETURN VALUE
  55. CURLMcode type, general libcurl multi interface error code.
  56. The return code is for the whole multi stack. Problems still might have
  57. occurred on individual transfers even when one of these functions return OK.
  58. .SH SEE ALSO
  59. .BR curl_multi_cleanup (3),
  60. .BR curl_multi_fdset (3),
  61. .BR curl_multi_info_read (3),
  62. .BR curl_multi_init (3),
  63. .BR the hiperfifo.c example