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();
}
