Closed dwwoelfel closed 3 years ago
Separate set_createsocketfunction
sounds better to me (with a comment explaining the difference).
I started work on this, but it didn't solve the underlying issue I was having, so I'm abandoning it for now. WIP is at https://github.com/dwwoelfel/ocurl/tree/set_createsocketfunction if anybody else wants a starting point.
The issue I thought I was having with seeing a socket in the set_socket_function
callback before seeing it in the opensocketfunction
callback is a different issue with libcurl
, described in more detail here https://github.com/curl/curl/issues/5747.
The current implementation of
set_opensocketfunction
has internal code creates the socket and then calls the provided callback with the new socket.Would it be possible to create a separate function that allows the user of ocurl to create the socket?
I'd like to use
opensocketfunction
andclosesocketfunction
to get more control over creating and releasing the sockets to make ocurl play more nicely with janestreet's Async. With the currentopensocketfunction
, I'll occasionally see the socket in theset_socket_function
callback before I see it in theopensocketfunction
callback.I'm happy to try to implement this if there's no technical reason why it's not possible. Before I start, it would be helpful to get some guidance. Should I just add a new function, e.g.
set_createsocketfunction
, or would it be better to make a breaking change to the existing function to accept a variant, e.g.| CreateSocket of (unit -> Unix.file_descr) | UseSocket of (Unix.file_descr -> unit)
?