Module Curl.MultiSource

Curl multi stack. Functions may raise Failure on critical errors

Sourcetype mt

type of Curl multi stack

Sourcetype curlPipelining =
  1. | PIPE_NOTHING
  2. | PIPE_HTTP1
  3. | PIPE_MULTIPLEX
Sourcetype curlMultiOption =
  1. | CURLMOPT_PIPELINING of curlPipelining list
  2. | CURLMOPT_MAXCONNECTS of int
  3. | CURLMOPT_MAX_PIPELINE_LENGTH of int
  4. | CURLMOPT_MAX_HOST_CONNECTIONS of int
  5. | CURLMOPT_MAX_TOTAL_CONNECTIONS of int
Sourceexception Error of string

exception raised on internal errors

Sourcetype cerror
Sourceval int_of_cerror : cerror -> int
Sourceexception CError of string * cerror * string

exception raised on libcurl errors : origin * code * message

Sourceval create : unit -> mt

create new multi stack

Sourceval add : mt -> t -> unit

add handle to multi stack

Sourceval remove : mt -> t -> unit

remove handle from multi stack (effectively halting the transfer)

Sourceval perform : mt -> int

perform pending data transfers (if any) on all handles currently in multi stack

  • returns

    the number of handles that still transfer data

Sourcetype waitfd_event =
  1. | CURL_WAIT_POLLIN
  2. | CURL_WAIT_POLLPRI
  3. | CURL_WAIT_POLLOUT
Sourcetype waitfd
Sourceval waitfd : Unix.file_descr -> waitfd_event list -> waitfd
Sourceval waitfd_fd : waitfd -> Unix.file_descr
Sourceval waitfd_isset : waitfd -> waitfd_event -> bool
Sourceval wait : ?timeout_ms:int -> ?extra_fds:waitfd list -> mt -> bool

wait till there are some active data transfers on multi stack

  • returns

    whether perform should be called

Sourceval poll : ?timeout_ms:int -> ?extra_fds:waitfd list -> mt -> bool

poll till there are some active data transfers on multi stack. Contrary to wait, this function does not return immediately when there are no pending transfer but waits for timeout_ms The module falls back to wait if this function is unavailable.

  • returns

    whether perform should be called

Sourceval remove_finished : mt -> (t * curlCode) option

remove finished handle from the multi stack if any. The returned handle may be reused

Sourceval cleanup : mt -> unit

destroy multi handle (all transfers are stopped, but individual Curl.t handles can be reused)

Sourcetype poll =
  1. | POLL_NONE
    (*

    none

    *)
  2. | POLL_IN
    (*

    available for reading

    *)
  3. | POLL_OUT
    (*

    available for writing

    *)
  4. | POLL_INOUT
    (*

    both

    *)
  5. | POLL_REMOVE
    (*

    socket not needed anymore

    *)

events that should be reported for the socket

Sourcetype fd_status =
  1. | EV_AUTO
    (*

    determine socket status automatically (with extra system call)

    *)
  2. | EV_IN
    (*

    socket has incoming data

    *)
  3. | EV_OUT
    (*

    socket is available for writing

    *)
  4. | EV_INOUT
    (*

    both

    *)

socket status

Sourceval set_socket_function : mt -> (Unix.file_descr -> poll -> unit) -> unit

set the function to receive notifications on what socket events are currently interesting for libcurl on the specified socket handle

Sourceval set_timer_function : mt -> (int -> unit) -> unit

set the function to receive notification when libcurl internal timeout changes, timeout value is in milliseconds

NB action_timeout should be called when timeout occurs

Sourceval set_closesocket_function : mt -> (Unix.file_descr -> unit) -> unit

set a function to be called to close a socket.

The underlying callback is a property of the easy handle, but cannot be stored there in these bindings because libcurl's use of this callback may occur outside the lifetime of the easy handle. This means that all easy handles added to a multi handle must use the same closesocket function.

Sourceval action_all : mt -> int

perform pending data transfers (if any) on all handles currently in multi stack (not recommended, action should be used instead)

  • returns

    the number of handles that still transfer data

Sourceval action_timeout : mt -> unit

inform libcurl that timeout occured

Sourceval action : mt -> Unix.file_descr -> fd_status -> int

action mt fd status informs libcurl about event on the specified socket. status specifies socket status. Perform pending data transfers.

  • returns

    the number of handles still active

Sourceval timeout : mt -> int

timeout mt polls multi handle for timeout (not recommended, use set_timer_function instead).

  • returns

    maximum allowed number of milliseconds to wait before calling libcurl to perform actions

Sourceval setopt : mt -> curlMultiOption -> unit