cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl use udp + CONNECT_ONLY

From: raydan <raydanhk_at_gmail.com>
Date: Fri, 18 Mar 2011 12:46:42 +0800

can i do the following things to make libcurl "support" udp?
i can send & receive using udp.

curl_socket_t opensocket (void *clientp,
                            curlsocktype purpose,
                            struct curl_sockaddr *address)
{

    address->socktype = SOCK_DGRAM;
    address->protocol = IPPROTO_UDP;
    return socket(address->family, address->socktype, address->protocol);
}

curl = curl_easy_init();
if(curl) {
        curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
        curl_easy_setopt(curl, CURLOPT_URL, "127.0.0.1:9999");
    curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);

    res = curl_easy_perform(curl);

    long sockextr;
    curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockextr);

    //curl_easy_send & curl_easy_recv here

    curl_easy_cleanup(curl);
}

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-18