Thousand Island v0.1.0 ThousandIsland.Socket View Source

Encapsulates a client connection's underlying socket, providing a facility to read, write, and otherwise manipulate a connection from a client. ThousandIsland.Socket instances are passed to the application layer of a server via the ThousandIsland.Handler.handle_connection/2 callback.

Link to this section Summary

Types

t()

A reference to a socket along with metadata describing how to use it

Functions

Closes the given socket.

Returns information in the form of t:ThousandIsland.Transport.socket_info() about the local end of the socket.

Returns information in the form of t:ThousandIsland.Transport.socket_info() about the remote end of the socket.

Returns available bytes on the given socket. Up to num_bytes bytes will be returned (0 can be passed in to get the next 'available' bytes, typically the next packet). If insufficient bytes are available, the functino can wait timeout milliseconds for data to arrive.

Sends the given data (specified as a binary or an IO list) on the given socket.

Shuts down the socket in the given direction.

Link to this section Types

A reference to a socket along with metadata describing how to use it

Link to this section Functions

Link to this function

close(socket)

View Source
close(t()) :: :ok

Closes the given socket.

Returns information in the form of t:ThousandIsland.Transport.socket_info() about the local end of the socket.

Returns information in the form of t:ThousandIsland.Transport.socket_info() about the remote end of the socket.

Link to this function

recv(socket, length \\ 0, timeout \\ :infinity)

View Source

Returns available bytes on the given socket. Up to num_bytes bytes will be returned (0 can be passed in to get the next 'available' bytes, typically the next packet). If insufficient bytes are available, the functino can wait timeout milliseconds for data to arrive.

Link to this function

send(socket, data)

View Source
send(t(), IO.iodata()) :: :ok | {:error, term()}

Sends the given data (specified as a binary or an IO list) on the given socket.

Link to this function

shutdown(socket, way)

View Source
shutdown(t(), ThousandIsland.Transport.way()) :: :ok

Shuts down the socket in the given direction.