diff options
-rw-r--r-- | docs/libcurl/curl_ws_recv.3 | 9 | ||||
-rw-r--r-- | lib/ws.c | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/docs/libcurl/curl_ws_recv.3 b/docs/libcurl/curl_ws_recv.3 index 3cbb5e6f9..3fd71c3e7 100644 --- a/docs/libcurl/curl_ws_recv.3 +++ b/docs/libcurl/curl_ws_recv.3 @@ -48,12 +48,17 @@ contains information about the received data. See the \fIcurl_ws_meta(3)\fP for details on that struct. .SH EXAMPLE .nf - + size_t rlen; + struct curl_ws_frame *meta; + char buffer[256]; + CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta); .fi .SH AVAILABILITY Added in 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. .SH "SEE ALSO" .BR curl_easy_setopt "(3), " curl_easy_perform "(3), " .BR curl_easy_getinfo "(3), " @@ -420,8 +420,8 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer, if(result) return result; if(!n) - /* still have nothing */ - goto out; + /* connection closed */ + return CURLE_GOT_NOTHING; wsp->stillb = data->state.buffer; wsp->stillblen = n; } @@ -483,7 +483,6 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer, wsp->stillb = NULL; } } -out: *metap = &wsp->frame; return CURLE_OK; } @@ -632,9 +631,14 @@ CURL_EXTERN CURLcode curl_ws_send(struct Curl_easy *data, const void *buffer, return CURLE_OK; /* raw mode sends exactly what was requested, and this is from within the write callback */ - if(Curl_is_in_callback(data)) + if(Curl_is_in_callback(data)) { + if(!data->conn) { + failf(data, "No associated connection"); + return CURLE_SEND_ERROR; + } result = Curl_write(data, data->conn->writesockfd, buffer, buflen, &written); + } else result = Curl_senddata(data, buffer, buflen, &written); |