curl-library
how do I create websocket client with libcurl (was: A quick hack to support Websocket with libcurl)
Date: Mon, 16 Mar 2015 17:23:16 +0900
Hello all,
I created a websocket client application with cURL 7.28.0 or before like
attached file.
# attached file is dummy code
I use multi_perform() for connecting server because the application works
progressively.
I mean it doesn't want to use blocking API like easy_perform().
It works fine until 7.28.0. But it dose not work since 7.29.0.
easy_send() returns CURL_SOCKET_BAD from Curl_getconnectinfo().
I guess because cURL changes the concept how to use easy and multi.
I hope it works fine for 7.40.0 or later.
So I have questions:
- that dummy code is correct how to use cURL API?
- there is another way to create the application?
Best regards,
thanks
===============
YAMADA Yasuharu
ACCESS CO., LTD.
Yasuharu.Yamada_at_access-company.com
2014-01-29 7:10 GMT+09:00 Daniel Stenberg <daniel_at_haxx.se>:
> On Sun, 26 Jan 2014, Frédéric Germain wrote:
>
> I actually made a github pull request there :
>> https://github.com/bagder/curl/pull/86
>>
>
> Thanks. I decided I need to wait with this until after this release just
> because it is a little too close to the release date.
>
> Additionally, when I apply this change test 571 myseriously start to fail
> for me (unless I use valgrind in the test), which tells me that somehow
> test 571 is timing dependent and this change alters the timing if in an
> ever so slight manner. It requires some research before I can push this.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
2014-01-26 18:09 GMT+09:00 Frédéric Germain <frederic.germain_at_gmail.com>:
> Hello all, I'm new here :)
>
> I'm writing because I found a way do kind of HTTP UPGRADE requests when we
> use multi handle, but as I'm wondering if there are cleaner ways, so I'm
> writing on the mailing list so that everyone can join in.
>
> Daniel told me it can be related to the work made for HTTP2 in
> lib/http2.[ch]
>
> I actually made a github pull request there :
> https://github.com/bagder/curl/pull/86
>
> So the idea is to be able to "detach" a easy handle from the multi handle.
> When it's in detached state, we can safely use curl_easy_send and
> curl_easy_recv :
>
> 1) add a easy handle wich represent your UPGRADE http request,
> with CURLOPT_HEADERFUNCTION set
> 2) on the last last header, do the following to detach the connection
> curl_easy_pause(easy_handle, CURLPAUSE_ALL);
> curl_easy_setopt(easy_handle, CURLOPT_FORBID_REUSE, 1);
> curl_easy_setopt(easy_handle, CURLOPT_CONNECT_ONLY, 1);
> 3) using the multi port you have, you can safely poll your socket
> for data, and use curl_easy_send/curl_easy_recv to exchange
> data with the connection
>
> Just need the little patch I sent, a websocket parser like wslay at
> http://wslay.sourceforge.net/.
> And I need to write a test for that...
>
> Comments are welcome
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
-- .
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
- text/x-csrc attachment: websocket_dummy.c