CURLOPT_BUFFERSIZE.3 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. .\" generated by cd2nroff 0.1 from CURLOPT_BUFFERSIZE.md
  2. .TH CURLOPT_BUFFERSIZE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_BUFFERSIZE \- receive buffer size
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_BUFFERSIZE, long size);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long specifying your preferred \fIsize\fP (in bytes) for the receive buffer
  12. in libcurl. The main point of this would be that the write callback gets
  13. called more often and with smaller chunks. Secondly, for some protocols, there
  14. is a benefit of having a larger buffer for performance.
  15. This is just treated as a request, not an order. You cannot be guaranteed to
  16. actually get the given size.
  17. This buffer size is by default \fICURL_MAX_WRITE_SIZE\fP (16kB). The maximum
  18. buffer size allowed to be set is \fICURL_MAX_READ_SIZE\fP (10MB). The minimum
  19. buffer size allowed to be set is 1024.
  20. DO NOT set this option on a handle that is currently used for an active
  21. transfer as that may lead to unintended consequences.
  22. The maximum size was 512kB until 7.88.0.
  23. Starting in libcurl 8.7.0, there is just a single transfer buffer allocated
  24. per multi handle. This buffer is used by all easy handles added to a multi
  25. handle no matter how many parallel transfers there are. The buffer remains
  26. allocated as long as there are active transfers.
  27. .SH DEFAULT
  28. CURL_MAX_WRITE_SIZE (16kB)
  29. .SH PROTOCOLS
  30. This functionality affects all supported protocols
  31. .SH EXAMPLE
  32. .nf
  33. int main(void)
  34. {
  35. CURL *curl = curl_easy_init();
  36. if(curl) {
  37. CURLcode res;
  38. curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");
  39. /* ask libcurl to allocate a larger receive buffer */
  40. curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 120000L);
  41. res = curl_easy_perform(curl);
  42. curl_easy_cleanup(curl);
  43. }
  44. }
  45. .fi
  46. .SH AVAILABILITY
  47. Added in curl 7.10
  48. .SH RETURN VALUE
  49. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  50. .SH SEE ALSO
  51. .BR CURLOPT_MAXFILESIZE (3),
  52. .BR CURLOPT_MAX_RECV_SPEED_LARGE (3),
  53. .BR CURLOPT_UPLOAD_BUFFERSIZE (3),
  54. .BR CURLOPT_WRITEFUNCTION (3)