Up

Module Udp

Signature

val udp_server : addr:string -> port:int -> f:(Async.Std.Socket.Address.Inet.t -> string -> unit Async.Std.Deferred.t) -> unit Async.Std.Deferred.t

udp_server addr port f except that f is called on every packet received with the address it was recieved from and the data received. The next packet will not be read until the Deferred returned by f is determined

val udp_client : addr:string -> port:int -> f:(Async.Std.Writer.t -> 'a Async.Std.Deferred.t) -> 'a Async.Std.Deferred.t

udp_client ~addr ~port ~f Same as tcp_client for udp

val connect : ([<
| `Inet of Async.Std.Unix.Inet_addr.t * int
| `Unix of string
] as 'a) Async.Std.Socket.Type.t -> addr:'a -> ([
| `Active
], 'a) Async.Std.Socket.t Async.Std.Deferred.t

connect socket_type ~addr connects a socket to addr

val tcp_server_generic : ?max_connections:int -> addr:'a -> stype:'a Async.Std.Socket.Type.t -> on_client_error:[
| `Ignore
| `Call of 'a -> exn -> unit
] -> f:('a -> Async.Std.Reader.t -> Async.Std.Writer.t -> unit Async.Std.Deferred.t) -> ?buffer_age_limit:[
| `At_most of Core.Std.Time.Span.t
| `Unlimited
] -> unit -> unit Async.Std.Deferred.t
val tcp_server_unix : ?max_connections:int -> addr:Async.Std.Socket.Address.Unix.t -> on_client_error:[
| `Ignore
| `Call of Async.Std.Socket.Address.Unix.t -> exn -> unit
] -> f:(Async.Std.Socket.Address.Unix.t -> Async.Std.Reader.t -> Async.Std.Writer.t -> unit Async.Std.Deferred.t) -> ?buffer_age_limit:[
| `At_most of Core.Std.Time.Span.t
| `Unlimited
] -> unit -> unit Async.Std.Deferred.t

tcp_server_unix ~addr ~port ?on_client_error ~f makes a tcp server over a unix domain socket, listening on a path indicated by addr. When clients connect f will be run and is passed the address of the client, and a Reader and Writer for communicating with the client. When the deferred returned by f is determined or f throws an exception the client socket and the reader and writer will be closed. The Deferred returned by the function as a whole will be determined when the server is ready to accept incoming connections