Represents a TCP socket.
Instances For
Creates a new TCP socket.
Connects a TCP socket to the specified address.
Sends data through a TCP socket.
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.
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.
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.
Binds a TCP socket to a specific address.
Accepts an incoming connection on a listening TCP socket.
Shuts down an incoming connection on a listening TCP socket.
Gets the remote address of a connected TCP socket.
Gets the local address of a bound TCP socket.
Enables the Nagle algorithm for a TCP socket.