This call is used in conjunction with
Stream.listen() to accept incoming
connections. Call this function after receiving a
to accept the connection. Before calling this function the client handle
must be initialized.
listen(callback) is called it is guaranteed that
this function will complete successfully the first time.
client should be a freshly-initialized stream.
Indicates whether the stream is writable (has space in buffers).
Starts listening for incoming connections.
backlog indicates the number of connections the kernel might queue.
When a new incoming connection is received the
callback is called.
staticreadStart(stream:Stream, callback:(result:Result<Buffer>) ‑> Void, ?allocate:(size:Int) ‑> Buffer):Void
callback whenever data is available on the stream.
The amount of data read is equal to the length of the buffer passed to
allocate is called immediately before each call to the
callback, to create buffer, into which the data will be read.
The end of the stream (typically, when the remote peer closes or shuts down
the connection) is indicated by
UVError.UV_EOF being passed to the
Note that this behavior is different from
Zero-length reads are possible, and do not indicate the end of stream. Instead,
they usually indicate
UVError.UV_EAGAIN inside libuv; libuv still calls the
callback in order to give the C user a chance to deallocate the data buffer.
This is not usually an issue in OCaml (which is the backend for eval target of
Haxe), so a wrapper of this function can usually simply ignore zero-length reads.
It is then also safe to convert
UVError.UV_EOF to zero-length reads in a
higher-level API, for consistency with reading files, and in accordance with OS
To read only once, call
eval.luv.Stream.readStop immediately, in the
Otherwise, the main callback will be called repeatedly.
Shuts down the write side of the stream.
eval.luv.Stream.write(), but won’t queue a write request if it can’t
be completed immediately.
Returns the number of bytes written.
staticwrite(stream:Stream, data:Array<Buffer>, callback:(result:Result<NoData>, bytesWritten:Int) ‑> Void):Result<NoData>
Writes the given buffer to the stream.
The second argument passed to the
callback is the number of bytes written.
libuv has an internal queue of writes, in part to implement retry. This means
that writes can be partial at the libuv API level, so it is possible to receive
UVError result, and for some data to have been successfully written.