Documentation

Std.Internal.UV.TCP

@[extern lean_uv_tcp_new]

Creates a new TCP socket.

@[extern lean_uv_tcp_connect]

Connects a TCP socket to the specified address.

@[extern lean_uv_tcp_send]

Sends data through a TCP socket.

@[extern lean_uv_tcp_recv]

Receives data from a TCP socket with a maximum size of size bytes. The promise resolves when data is available or an error occurs. If data is received, it’s wrapped in .some. If EOF is reached, the result is .none, indicating no more data is available. Receiving data in parallel on the same socket is not supported. Instead, we recommend binding multiple sockets to the same address. Furthermore calling this function in parallel with waitReadable is not supported.

@[extern lean_uv_tcp_wait_readable]

Returns an IO.Promise that resolves to true once socket has data available for reading, or to false if socket is closed before that. Calling this function twice on the same Socket or in parallel with recv? is not supported.

@[extern lean_uv_tcp_cancel_recv]

Cancels a receive operation in the form of recv? or waitReadable if there is currently one pending. This resolves their returned IO.Promise to none. This function is considered dangerous, as improper use can cause data loss, and is therefore not exposed to the top-level API.

Note that this function is idempotent and as such can be called multiple times on the same socket without causing errors, in particular also without a receive running in the first place.

@[extern lean_uv_tcp_bind]

Binds a TCP socket to a specific address.

@[extern lean_uv_tcp_listen]
opaque Std.Internal.UV.TCP.Socket.listen (socket : Socket) (backlog : UInt32) :

Starts listening for incoming connections on a TCP socket.

@[extern lean_uv_tcp_accept]

Accepts an incoming connection on a listening TCP socket.

@[extern lean_uv_tcp_shutdown]

Shuts down an incoming connection on a listening TCP socket.

@[extern lean_uv_tcp_getpeername]

Gets the remote address of a connected TCP socket.

@[extern lean_uv_tcp_getsockname]

Gets the local address of a bound TCP socket.

@[extern lean_uv_tcp_nodelay]

Enables the Nagle algorithm for a TCP socket.

@[extern lean_uv_tcp_keepalive]
opaque Std.Internal.UV.TCP.Socket.keepAlive (socket : Socket) (enable : Int8) (delay : UInt32) :

Enables TCP keep-alive for a socket. If delay is less than 1 then UV_EINVAL is returned.