Anoma.Node.Transport.TCP.Listener (Anoma v0.29.0)
I am a TCP listener. I listen on a given interface and port for incoming connections.
When I receive a connection, I create a new TCPServer process to further handle the connection.
Public API
I provide the following public functionality:
Summary
Functions
I am the child spec for a TCP listener.
I return the port on which I am listening
I am the init function for a TCP listener process.
I return the port on which I am listening. This is useful for the examples where I start up using a random port.
Types
hostname()
@type hostname() :: :inet.socket_address() | :inet.hostname()
Shorthand type for socket.
port_number()
@type port_number() :: :inet.port_number()
Shorthand type for port number.
@type t() :: %Anoma.Node.Transport.TCP.Listener{ host: hostname() | nil, node_id: String.t() | nil, port: port_number() | nil, socket: :inet.socket() | nil }
I am the state of a TCP listener.
My fields contain information to listen for TCP connection with a remote node.
Fields
:node_id
- The key of this router. This value is used to announce myself to other:host
- The host address of the remote tcp server.:port
- The port of the remote tcp server.:socket
- The socket of an accepted connection.
Functions
child_spec(init_arg)
@spec child_spec([any()]) :: Supervisor.child_spec()
I am the child spec for a TCP listener.
I ensure that TCP listeners are not restarted if they terminate.
handle_call(msg, from, state)
I return the port on which I am listening
init(args)
I am the init function for a TCP listener process.
Options
:host
- The host to whom I will listen.:port
- The port on which I will listen.:node_id
- The key of the local node.
port(tcp_server)
@spec port(GenServer.server()) :: port_number()
I return the port on which I am listening. This is useful for the examples where I start up using a random port.
start_link(args)
@spec start_link([any()]) :: GenServer.on_start()