Woops, sorry
dummy code was wrong.
I attached correct dummy code.
2015-03-17 9:54 GMT+09:00 YAMADA Yasuharu <
[email protected]>:
> Hi Danial,
>
> 2015-03-16 19:56 GMT+09:00 Daniel Stenberg <[email protected]>:
>
>> I hope it works fine for 7.40.0 or later.
>>>
>>
>> Why don't you try and then tell us?
>
>
> sorry I did not focus this problem long time.
> I try to test 7.28.0~7.40.0 these days.
>
> So I have questions:
>>> - that dummy code is correct how to use cURL API?
>>>
>>
>> It lacks a lot of checks and it uses a busy-loop so I wouldn't call it
>> correct, but I believe it should work.
>>
>
> I'd like to confirm.
> Is it correct how to use cURL API like that dummy code?
>
> Set a few break-point and figure out what happens?
>
>
> curl_multi_perform() CONNECT to server
> curl_easy_send()
> -> easy_connection()
> -> Curl_getconnectinfo()
> -> data->multi_easy is NULL because it does not use easy_perform()
> -> return CURL_SOCKET_BAD by Curl_getconnectinfo()
>
> # I guess
> https://github.com/fredericgermain/curl/commit/b9baee6e347c193d8a75c61bcdffad24e85aa1c8
> is convenient for this issue.
>
> - there is another way to create the application?
>>
>> Skip libcurl and just connect a socket to the server? You're not using
>> libcurl very much anyway...
>
>
> The application is web browser and we use libcurl for it more than 4 years.
> I know it can connect to websocket server through socket.
> but for browsing, the connection through proxy, authentication, SSL/TLS,
> etc.
> It is difficult to use socket directory.
>
> Best regards,
> thanks
> ===============
> YAMADA Yasuharu
> ACCESS CO., LTD.
> [email protected]
>
>
--
.
CURLM* multiHandle;
CULR* handle;
websocket_init()
{
multiHandle = curl_multi_init();
curl_multi_setopt(multiHandle, CURLMOPT_MAXCONNECTS, 1L);
handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_MAXCONNECTS, 1L);
curl_easy_setopt(handle, CURLOPT_URL, "http://example.com");
curl_easy_setopt(handle, CURLOPT_CONNECT_ONLY, 1L);
curl_multi_add_handle(multiHandle, handle);
}
websocket_connect()
{
while (curl_multi_perform(multiHandle, &runningHandles) == CURLM_CALL_MULTI_PERFORM) { }
CURLMsg* msg = curl_multi_info_read((CURLM*)m_multiHandle, &messagesInQueue);
if (!msg) {
// call again websocket_connect()
return false;
}
else {
// call websocket_send()
return true;
}
}
websocket_send(data)
{
curl_easy_send(handle, data, len, &curl_out_len);
}
websocket_recv()
{
curl_easy_recv(handle, recvData, recvDataLen, &inoutLen);
}
main()
{
websocket_init()
while (!websocket_connect()) {
// do something
}
//curl_easy_setopt(handle, CURLOPT_CONNECT_ONLY, 0L);
websocket_send("GET URL HTTP/1.1\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n....");
websocket_recv();
websocket_send("sending data...");
websocket_recv();
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html