curl_ws_recv.3 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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 https://curl.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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH curl_ws_recv 3 "12 Jun 2022" "libcurl" "libcurl"
  26. .SH NAME
  27. curl_ws_recv - receive WebSocket data
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/easy.h>
  31. CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen,
  32. size_t *recv, const struct curl_ws_frame **meta);
  33. .fi
  34. .SH DESCRIPTION
  35. This function call is EXPERIMENTAL.
  36. Retrieves as much as possible of a received WebSocket data fragment into the
  37. \fBbuffer\fP, but not more than \fBbuflen\fP bytes. \fIrecv\fP is set to the
  38. number of bytes actually stored.
  39. If there is more fragment data to deliver than what fits in the provided
  40. \fIbuffer\fP, libcurl returns a full buffer and the application needs to call
  41. this function again to continue draining the buffer.
  42. The \fImeta\fP pointer gets set to point to a \fIconst struct curl_ws_frame\fP
  43. that contains information about the received data. See the
  44. \fIcurl_ws_meta(3)\fP for details on that struct.
  45. .SH EXAMPLE
  46. .nf
  47. size_t rlen;
  48. const struct curl_ws_frame *meta;
  49. char buffer[256];
  50. CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
  51. .fi
  52. .SH AVAILABILITY
  53. Added in 7.86.0.
  54. .SH RETURN VALUE
  55. Returns \fBCURLE_OK\fP if everything is okay, and a non-zero number for
  56. errors. Returns \fBCURLE_GOT_NOTHING\fP if the associated connection is
  57. closed.
  58. Instead of blocking, the function returns \fBCURLE_AGAIN\fP. The correct
  59. behavior is then to wait for the socket to signal readability before calling
  60. this function again.
  61. .SH "SEE ALSO"
  62. .BR curl_easy_setopt "(3), " curl_easy_perform "(3), "
  63. .BR curl_easy_getinfo "(3), "
  64. .BR curl_ws_send "(3), " libcurl-ws "(3), "