AFAIK you are talking about the Sec-WebSocket-Protocol header and that is a normal HTTP header so you can add it using the normal http header functions.
So if this had been C and not js then: struct curl_slist *slist = curl_slist_append (NULL, "Sec-WebSocket-Protocol: protocol"); curl_easy_setopt (curl, CURLOPT_HTTPHEADER, slist); to set it to the value "protocol". /HH Den tors 25 maj 2023 kl 20:03 skrev Johny Bravo via curl-library < curl-library@lists.haxx.se>: > No, I have wss server written in libwebsockets that runs on my server. > Part of libwebsocket init is to set "port name" > const char * name => Protocol name that must match the one given in the > client Javascript new WebSocket(url, 'protocol') name > > But I am not sure, how to read from my server using libCURL if I setup > protocol name on the server. If I leave name empty, it does not work either > plus JS version does not work either. > ---------- Původní e-mail ---------- > Od: Dan Fandrich via curl-library <curl-library@lists.haxx.se> > Komu: curl-library@lists.haxx.se > Kopie: Dan Fandrich <d...@coneharvesters.com> > Datum: 25. 5. 2023 19:25:16 > Předmět: Re: WebSocket custom port name as in JavaScript websockets > > On Thu, May 25, 2023 at 05:23:58PM +0200, Johny Bravo via curl-library > wrote: > > I have tried websocket API, but I cannot get it working and receive > message. > > If I use the ws in JavaScript, I have: > > > > var socket = new WebSocket( "wss://some_url", "example"); > > > > However, I dont know, how to set "example" port in libCURL API. I have > tried > > It sounds like you're trying to use libcurl to talk to a browser. My > understanding is that this will never work, because WebSockets is for > peer-to-server communication and not peer-to-peer and libcurl provides > only > a client WebSockets implementation, like a browser does. > > Dan > -- > Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library > Etiquette: https://curl.se/mail/etiquette.html > > -- > Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library > Etiquette: https://curl.se/mail/etiquette.html >
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html