cURL / Mailing Lists / curl-library / Single Mail


Re: Working with curl connections as with sockets.

From: tetetest tetetest <>
Date: Fri, 25 Apr 2008 16:22:36 +0400

* Daniel Stenberg <> [Fri, 25 Apr 2008 12:09:09 +0200

> > - in case of SSL connections, which descriptor is returned? The
> > connected to the server, or the SSL engine's handle?
> The socket. So you need to use a SSL library that you can hand a
> and tell it that here's an established SSL connection. I'm not sure
this is
> really properly feasable though...

I am afraid it isn't. After SSL connection is established, you must use
the SSL session. You cannot re-establish sessions on the fly (that's
what SSL is basically for; otherwise an intruder could hijack an
existing session without any trouble).

> > I still think that libcurl can handle its sockets better than the
> > application - simply because libcurl knows more about the socket.
> Providing
> > an interface for sending/receiving the data will greatly simplify
> usage
> > of libcurl in aplications using CURLOPT_CONNECT_ONLY.
> Yeah, especially in the case with SSL it is a bit messy for the app.
> Adding curl_socket_recv() and curl_socket_send() would possibly make
> sense and
> not involve too many hoops and weird stuff. These functions would then
> basically require that you do a successful CURLOPT_CONNECT_ONLY first.
> But will it be enough with just these two ones then? I'm a bit scared
> it'll be like opening pandora's box here and we'll soon have to add
> and more to make this API usable when going down this road.

'Send' for sending, 'recv' for receiving, and something like 'poll' (or
'select') to check if data is available for reading or sendable. That
should be pretty enough for everyone. Other functionality (like reading
strings in string-oriented protocols) could easily be implemented using
these three basic functions.

And those geeks who send OOB data over non-blocking sockets should
resort to good old CURLINFO_LASTSOCKET.

> > So, could such interface be possibly implemented? Please. :)
> Me being open to the idea of course doesn't make it automatically
> happen. If you really want it to start happening you better step up
> and start doing some work on it.

Ok... Off to reading the docs and sources. :)
Received on 2008-04-25