package luv
 sectionYPositions = computeSectionYPositions($el), 10)"
  x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
  >
  
  
On This Page
  
  
  Binding to libuv: cross-platform asynchronous I/O
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
  
    
      luv-0.5.13.tar.gz
    
    
        
    
  
  
  
    
  
  
    
  
        sha256=59a616bce6581bd7ed427dd6a640ff359f2a54eedb5deb5feeb35431756c2252
    
    
  md5=fa4875137341933d1308e432c652b2cd
    
    
  doc/index.html
Luv
Luv is a binding to libuv, the cross-platform C library that does asynchronous I/O in Node.js and runs Node's main loop.
let () =
  Luv.DNS.getaddrinfo ~family:`INET ~node:"google.com" ~service:"80" ()
      begin fun result ->
    let address = (List.hd (Result.get_ok result)).addr in
    let socket = Luv.TCP.init () |> Result.get_ok in
    Luv.TCP.connect socket address begin fun _ ->
      Luv.Stream.write socket [Luv.Buffer.from_string "GET / HTTP/1.1\r\n\r\n"]
        (fun _ _ -> Luv.Stream.shutdown socket ignore);
      Luv.Stream.read_start socket (function
        | Error `EOF -> Luv.Handle.close socket ignore
        | Error _ -> exit 2
        | Ok response -> print_string (Luv.Buffer.to_string response))
    end
  end;
  ignore (Luv.Loop.run () : bool)This is the auto-generated API reference. For more conceptual information and examples, see:
- Project page
- User guide
- Examples, which are presented in the user guide.
API reference
Basics
- Luv.Error— error handling
- Luv.Loop— event loops
- Luv.Buffer— byte buffers
- Luv.Handle— persistent objects (sockets, etc.)
- Luv.Stream— base type for TCP sockets, pipes, TTY handles
- Luv.Request— contexts for asynchronous requests
Main interface
- Luv.Timer— timers
- Luv.Signal— signals
- Luv.Process— subprocesses
- Luv.TCP— TCP sockets
- Luv.UDP— UDP sockets
- Luv.DNS— DNS
- Luv.Pipe— pipes
- Luv.TTY— consoles
- Luv.File— file operations
- Luv.FS_event— filesystem events
System threads
- Luv.Thread_pool— libuv thread pool
- Luv.Thread— general system threads
- Luv.TLS— thread-local storage
- Luv.Once— once-only barriers
- Luv.Mutex— mutexes
- Luv.Rwlock— read-write locks
- Luv.Semaphore— semaphores
- Luv.Condition— condition variables
- Luv.Barrier— barriers
Miscellaneous
- Luv.Env— environment variables
- Luv.Time— current time
- Luv.Path— relevant directories
- Luv.Random— system entropy source
- Luv.Sockaddr— network addresses
- Luv.Network— network interfaces and hostname
- Luv.FS_poll— filesystem polling
- Luv.Poll— file descriptor polling
- Luv.Resource— resource usage
- Luv.System_info— system information
- Luv.Pid— process ids
- Luv.Os_fd— system file descriptor interop
- Luv.DLL— dynamic linking
- Luv.Passwd— current user information
- Luv.Async— inter-loop communication
- Luv.Metrics— loop metrics
- Luv.Prepare— pre-I/O callbacks
- Luv.Check— post-I/O callbacks
- Luv.Idle— per-iteration callbacks
- Luv.String— UTF-16 manipulation for Windows
- Luv.Version— libuv version
- Luv.Require— feature checks
 sectionYPositions = computeSectionYPositions($el), 10)"
  x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
  >
  
  
  On This Page