package uwt

  1. Overview
  2. Docs

Uwt main module

Basic overview:

  • naming conventions mirror the conventions of libuv, so you can easily consult the official libuv manual. Only the differences are explained here.
  • Requests are translated to lwt-threads, therefore uv_req_t is kept internal.
  • Callbacks that are called continually are most of the time not translated to the usual lwt semantic.
  • Uwt is not compatible with lwt.unix. It's not a further Lwt_engine in addition to select and libev.
  • Uwt is not thread safe. All uwt functions should be called from your main thread.
  • Uwt is in beta stage. The interface is likely to change in the first official release. Feel free to open an issue an make suggestions about it :)

Please notice, that there are subtle differences compared to lwt.unix. Because all requests are accomplished by libuv (sometimes in parallel in different threads), you don't have that kind of low level control, that you have with lwt.unix. For example it's not guaranteed that in the following example only one operation is executed:

Lwt.pick [ op_timeout ; op_read ; op_write; op_xyz ]
include module type of Uwt_base with type error = Uwt_base.error with type 'a uv_result = 'a Uwt_base.uv_result with type file = Uwt_base.file with type sockaddr = Uwt_base.sockaddr with type 'a Int_result.t = 'a Uwt_base.Int_result.t with type Fs_types.uv_open_flag = Uwt_base.Fs_types.uv_open_flag with type Fs_types.file_kind = Uwt_base.Fs_types.file_kind with type Fs_types.symlink_mode = Uwt_base.Fs_types.symlink_mode with type Fs_types.access_permission = Uwt_base.Fs_types.access_permission with type Fs_types.stats = Uwt_base.Fs_types.stats with type Misc.timeval = Uwt_base.Misc.timeval with type Misc.rusage = Uwt_base.Misc.rusage with type Misc.cpu_times = Uwt_base.Misc.cpu_times with type Misc.cpu_info = Uwt_base.Misc.cpu_info with type Misc.interface_address = Uwt_base.Misc.interface_address with type Misc.handle_type = Uwt_base.Misc.handle_type with type Misc.version = Uwt_base.Misc.version
type error = Uwt_base.error =
  1. | E2BIG
  2. | EACCES
  3. | EADDRINUSE
  4. | EADDRNOTAVAIL
  5. | EAFNOSUPPORT
  6. | EAGAIN
  7. | EAI_ADDRFAMILY
  8. | EAI_AGAIN
  9. | EAI_BADFLAGS
  10. | EAI_BADHINTS
  11. | EAI_CANCELED
  12. | EAI_FAIL
  13. | EAI_FAMILY
  14. | EAI_MEMORY
  15. | EAI_NODATA
  16. | EAI_NONAME
  17. | EAI_OVERFLOW
  18. | EAI_PROTOCOL
  19. | EAI_SERVICE
  20. | EAI_SOCKTYPE
  21. | EALREADY
  22. | EBADF
  23. | EBUSY
  24. | ECANCELED
  25. | ECHARSET
    (*

    Windows filenames (and similar parameters) are expected to be in utf8. ECHARSET is returned, if one parameter contains invalid unicode. Futhermore, ECHARSET will be returned, if your strings contain null bytes (on *nix, too!)

    *)
  26. | ECONNABORTED
  27. | ECONNREFUSED
  28. | ECONNRESET
  29. | EDESTADDRREQ
  30. | EEXIST
  31. | EFAULT
  32. | EFBIG
  33. | EHOSTUNREACH
  34. | EINTR
  35. | EINVAL
  36. | EIO
  37. | EISCONN
  38. | EISDIR
  39. | ELOOP
  40. | EMFILE
  41. | EMSGSIZE
  42. | ENAMETOOLONG
  43. | ENETDOWN
  44. | ENETUNREACH
  45. | ENFILE
  46. | ENOBUFS
  47. | ENODEV
  48. | ENOENT
  49. | ENOMEM
  50. | ENONET
  51. | ENOPROTOOPT
  52. | ENOSPC
  53. | ENOSYS
  54. | ENOTCONN
  55. | ENOTDIR
  56. | ENOTEMPTY
  57. | ENOTSOCK
  58. | ENOTSUP
  59. | EPERM
  60. | EPIPE
  61. | EPROTO
  62. | EPROTONOSUPPORT
  63. | EPROTOTYPE
  64. | ERANGE
  65. | EROFS
  66. | ESHUTDOWN
  67. | ESPIPE
  68. | ESRCH
  69. | ETIMEDOUT
  70. | ETXTBSY
  71. | EXDEV
  72. | UNKNOWN
  73. | EOF
  74. | ENXIO
  75. | UWT_EFATAL
    (*

    something happened that the author of uwt didn't expect. Probably a bug or a the api of libuv has changed in the meanwhile

    *)
val strerror : error -> string

error message for the given error code

val err_name : error -> string

error name for the given error code

val to_unix_error : error -> Unix.error

map error to Unix.error , Unix.EUNKNOWNERR is used, if mapping is not possible

val of_unix_error : Unix.error -> error

get back the original Uwt.error from an exception raised by a Uwt function

type 'a uv_result = 'a Uwt_base.uv_result
type ('a, 'b) o_result = ('a, 'b) Stdlib.result =
  1. | Ok of 'a
  2. | Error of 'b
  • deprecated please use Result.result instead
type 'a result = ('a, error) o_result
  • deprecated please use Result.result or uv_result instead
module Int_result : sig ... end
type file = Uwt_base.file

abstract type for a file descriptor

type sockaddr = Uwt_base.sockaddr
type buf = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
val stdin : file
val stdout : file
val stderr : file
module Fs_types : sig ... end
module type Fs_functions = sig ... end
module Conv : sig ... end
module Misc : sig ... end
module Sys_info : sig ... end
module Main : sig ... end

Analogue to Lwt_main

module Fs : sig ... end
module Handle : sig ... end
module Handle_ext : sig ... end
module Handle_fileno : sig ... end
module Stream : sig ... end
module Pipe : sig ... end
module Tcp : sig ... end
module Udp : sig ... end
module Tty : sig ... end
module Timer : sig ... end
module Signal : sig ... end
module Poll : sig ... end
module Fs_event : sig ... end
module Fs_poll : sig ... end
module Process : sig ... end
module Dns : sig ... end
module Unix : sig ... end
module C_worker : sig ... end
OCaml

Innovation. Community. Security.