ThousandIsland.Socket (Thousand Island v0.4.6) View Source
Encapsulates a client connection's underlying socket, providing a facility to read, write, and otherwise manipulate a connection from a client.
Link to this section Summary
Functions
Closes the given socket. Note that a socket is automatically closed when the handler process which owns it terminates
Handshakes the underlying socket if it is required (as in the case of SSL sockets, for example).
Returns information in the form of t:ThousandIsland.Transport.socket_info()
about the local end of the socket.
Returns information about the protocol negotiated during transport handshaking (if any).
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 function can wait timeout
milliseconds for data to arrive.
Returns whether or not this protocol is secure.
Sends the given data (specified as a binary or an IO list) on the given socket.
Sends the contents of the given file based on the provided offset & length
Sets the given flags on the socket
Shuts down the socket in the given direction.
Link to this section Types
Specs
t() :: %ThousandIsland.Socket{ acceptor_id: String.t(), connection_id: String.t(), socket: ThousandIsland.Transport.socket(), transport_module: module() }
A reference to a socket along with metadata describing how to use it
Link to this section Functions
Specs
close(t()) :: :ok
Closes the given socket. Note that a socket is automatically closed when the handler process which owns it terminates
Specs
Handshakes the underlying socket if it is required (as in the case of SSL sockets, for example).
Specs
local_info(t()) :: ThousandIsland.Transport.socket_info()
Returns information in the form of t:ThousandIsland.Transport.socket_info()
about the local end of the socket.
Specs
negotiated_protocol(t()) :: ThousandIsland.Transport.negotiated_protocol_info()
Returns information about the protocol negotiated during transport handshaking (if any).
Specs
peer_info(t()) :: ThousandIsland.Transport.socket_info()
Returns information in the form of t:ThousandIsland.Transport.socket_info()
about the remote end of the socket.
Specs
recv(t(), non_neg_integer(), timeout()) :: ThousandIsland.Transport.on_recv()
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 function can wait timeout
milliseconds for data to arrive.
Specs
Returns whether or not this protocol is secure.
Specs
send(t(), IO.chardata()) :: :ok | {:error, term()}
Sends the given data (specified as a binary or an IO list) on the given socket.
Specs
sendfile(t(), String.t(), non_neg_integer(), non_neg_integer()) :: {:ok, non_neg_integer()} | {:error, String.t()}
Sends the contents of the given file based on the provided offset & length
Specs
setopts(t(), ThousandIsland.Transport.socket_options()) :: :ok | {:error, String.t()}
Sets the given flags on the socket
Specs
shutdown(t(), ThousandIsland.Transport.way()) :: :ok
Shuts down the socket in the given direction.