mirror of
https://codeberg.org/kiss-community/repo
synced 2025-01-05 01:10:07 -07:00
61 lines
1.9 KiB
Groff
61 lines
1.9 KiB
Groff
.\" generated by cd2nroff 0.1 from curl_ws_recv.md
|
|
.TH curl_ws_recv 3 "2024-11-09" libcurl
|
|
.SH NAME
|
|
curl_ws_recv \- receive WebSocket data
|
|
.SH SYNOPSIS
|
|
.nf
|
|
#include <curl/curl.h>
|
|
|
|
CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen,
|
|
size_t *recv, const struct curl_ws_frame **meta);
|
|
.fi
|
|
.SH DESCRIPTION
|
|
This function call is EXPERIMENTAL.
|
|
|
|
Retrieves as much as possible of a received WebSocket data fragment into the
|
|
\fBbuffer\fP, but not more than \fBbuflen\fP bytes. \fIrecv\fP is set to the
|
|
number of bytes actually stored.
|
|
|
|
If there is more fragment data to deliver than what fits in the provided
|
|
\fIbuffer\fP, libcurl returns a full buffer and the application needs to call this
|
|
function again to continue draining the buffer.
|
|
|
|
If the function call is successful, the \fImeta\fP pointer gets set to point to a
|
|
\fIconst struct curl_ws_frame\fP that contains information about the received
|
|
data. That struct must not be freed and its contents must not be relied upon
|
|
anymore once another WebSocket function is called. See the \fIcurl_ws_meta(3)\fP for
|
|
details on that struct.a
|
|
.SH PROTOCOLS
|
|
This functionality affects ws only
|
|
.SH EXAMPLE
|
|
.nf
|
|
int main(void)
|
|
{
|
|
size_t rlen;
|
|
const struct curl_ws_frame *meta;
|
|
char buffer[256];
|
|
CURL *curl = curl_easy_init();
|
|
if(curl) {
|
|
CURLcode res = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
|
|
if(res)
|
|
printf("error: %s\\n", curl_easy_strerror(res));
|
|
}
|
|
}
|
|
.fi
|
|
.SH AVAILABILITY
|
|
Added in curl 7.86.0
|
|
.SH RETURN VALUE
|
|
Returns \fBCURLE_OK\fP if everything is okay, and a non\-zero number for
|
|
errors. Returns \fBCURLE_GOT_NOTHING\fP if the associated connection is
|
|
closed.
|
|
|
|
Instead of blocking, the function returns \fBCURLE_AGAIN\fP. The correct
|
|
behavior is then to wait for the socket to signal readability before calling
|
|
this function again.
|
|
.SH SEE ALSO
|
|
.BR curl_easy_getinfo (3),
|
|
.BR curl_easy_perform (3),
|
|
.BR curl_easy_setopt (3),
|
|
.BR curl_ws_send (3),
|
|
.BR libcurl-ws (3)
|