curl_ws_send.3 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, 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_send 3 "12 Jun 2022" "libcurl 7.85.0" "libcurl Manual"
  26. .SH NAME
  27. curl_ws_send - send WebSocket data
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/easy.h>
  31. CURLcode curl_ws_send(CURL *curl, const void *buffer, size_t buflen,
  32. size_t *sent, curl_off_t fragsize,
  33. unsigned int flags);
  34. .fi
  35. .SH DESCRIPTION
  36. This function call is EXPERIMENTAL.
  37. Send the specific message fragment over an established WebSocket
  38. connection. The \fIbuffer\fP holds the data to send and it is \fIbuflen\fP
  39. number of payload bytes in that memory area.
  40. \fIsent\fP is returned as the number of payload bytes actually sent.
  41. To send a (huge) fragment using multiple calls with partial content per
  42. invoke, set the \fICURLWS_OFFSET\fP bit and the \fIfragsize\fP argument as the
  43. total expected size for the first part, then set the \fICURLWS_OFFSET\fP with
  44. a zero \fIfragsize\fP for the following parts.
  45. If not sending a partial fragment or if this is raw mode, \fIfragsize\fP
  46. should be set to zero.
  47. If \fBCURLWS_RAW_MODE\fP is enabled in \fICURLOPT_WS_OPTIONS(3)\fP, the
  48. \fBflags\fP argument should be set to 0.
  49. .SH FLAGS
  50. .IP CURLWS_TEXT
  51. The buffer contains text data. Note that this makes a difference to WebSocket
  52. but libcurl itself will not make any verification of the content or
  53. precautions that you actually send valid UTF-8 content.
  54. .IP CURLWS_BINARY
  55. This is binary data.
  56. .IP CURLWS_CONT
  57. This is not the final fragment of the message, which implies that there will
  58. be another fragment coming as part of the same message where this bit is not
  59. set.
  60. .IP CURLWS_CLOSE
  61. Close this transfer.
  62. .IP CURLWS_PING
  63. This as a ping.
  64. .IP CURLWS_PONG
  65. This as a pong.
  66. .IP CURLWS_OFFSET
  67. The provided data is only a partial fragment and there will be more in a
  68. following call to \fIcurl_ws_send()\fP. When sending only a piece of the
  69. fragment like this, the \fIfragsize\fP must be provided with the total
  70. expected fragment size in the first call and it needs to be zero in subsequent
  71. calls.
  72. .SH EXAMPLE
  73. .nf
  74. .fi
  75. .SH AVAILABILITY
  76. Added in 7.86.0.
  77. .SH RETURN VALUE
  78. .SH "SEE ALSO"
  79. .BR curl_easy_setopt "(3), " curl_easy_perform "(3), "
  80. .BR curl_easy_getinfo "(3), "
  81. .BR curl_ws_recv "(3) "