Lines Matching refs:curl
12 * are also available at https://curl.se/docs/copyright.html.
21 * SPDX-License-Identifier: curl
29 /* curl stuff */
31 #include <curl/curl.h>
43 static CURLcode ping(CURL *curl, const char *send_payload)
47 curl_ws_send(curl, send_payload, strlen(send_payload), &sent, 0,
55 static CURLcode recv_pong(CURL *curl, const char *expected_payload)
60 CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
84 static void websocket_close(CURL *curl)
88 curl_ws_send(curl, "", 0, &sent, 0, CURLWS_CLOSE);
93 static CURLcode pingpong(CURL *curl, const char *payload)
98 res = ping(curl, payload);
103 res = recv_pong(curl, payload);
108 websocket_close(curl);
111 websocket_close(curl);
120 CURL *curl;
133 curl = curl_easy_init();
134 if(curl) {
135 curl_easy_setopt(curl, CURLOPT_URL, url);
138 curl_easy_setopt(curl, CURLOPT_USERAGENT, "ws-pingpong");
139 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
140 curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 2L); /* websocket style */
141 res = curl_easy_perform(curl);
144 res = pingpong(curl, payload);
147 curl_easy_cleanup(curl);