curl_easy_recv.3 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at http://curl.haxx.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH curl_easy_recv 3 "29 April 2008" "libcurl 7.18.2" "libcurl Manual"
  24. .SH NAME
  25. curl_easy_recv - receives raw data on an "easy" connection
  26. .SH SYNOPSIS
  27. .B #include <curl/easy.h>
  28. .sp
  29. .BI "CURLcode curl_easy_recv( CURL *" curl ", void *" buffer ","
  30. .BI "size_t " buflen ", size_t *" n ");"
  31. .ad
  32. .SH DESCRIPTION
  33. This function receives raw data from the established connection. You may use
  34. it together with \fIcurl_easy_send(3)\fP to implement custom protocols using
  35. libcurl. This functionality can be particularly useful if you use proxies
  36. and/or SSL encryption: libcurl will take care of proxy negotiation and
  37. connection set-up.
  38. \fBbuffer\fP is a pointer to your buffer that will get the received
  39. data. \fBbuflen\fP is the maximum amount of data you can get in that
  40. buffer. The variable \fBn\fP points to will receive the number of received
  41. bytes.
  42. To establish the connection, set \fBCURLOPT_CONNECT_ONLY\fP option before
  43. calling \fIcurl_easy_perform(3)\fP. Note that \fIcurl_easy_recv(3)\fP does not
  44. work on connections that were created without this option.
  45. You must ensure that the socket has data to read before calling
  46. \fIcurl_easy_recv(3)\fP, otherwise the call will return \fBCURLE_AGAIN\fP -
  47. the socket is used in non-blocking mode internally. Use
  48. \fIcurl_easy_getinfo(3)\fP with \fBCURLINFO_LASTSOCKET\fP to obtain the
  49. socket; use your operating system facilities like \fIselect(2)\fP to check if
  50. it has any data you can read.
  51. .SH AVAILABILITY
  52. Added in 7.18.2.
  53. .SH RETURN VALUE
  54. On success, returns \fBCURLE_OK\fP, stores the received data into
  55. \fBbuffer\fP, and the number of bytes it actually read into \fB*n\fP.
  56. On failure, returns the appropriate error code.
  57. If there is no data to read, the function returns \fBCURLE_AGAIN\fP. Use
  58. your operating system facilities to wait until the data is ready, and retry.
  59. .SH EXAMPLE
  60. See \fBsendrecv.c\fP in \fBdocs/examples\fP directory for usage example.
  61. .SH "SEE ALSO"
  62. .BR curl_easy_setopt "(3), " curl_easy_perform "(3), "
  63. .BR curl_easy_getinfo "(3), "
  64. .BR curl_easy_send "(3) "