Anoma.Node.Transport.TCP.Listener (Anoma v0.25.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

Types

Shorthand type for socket.

Shorthand type for port number.

t()

I am the state of a TCP listener.

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

@type hostname() :: :inet.socket_address() | :inet.hostname()

Shorthand type for socket.

Link to this type

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

Link to this function

child_spec(init_arg)

I am the child spec for a TCP listener.

I ensure that TCP listeners are not restarted if they terminate.

Link to this function

handle_call(msg, from, state)

I return the port on which I am listening

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.
Link to this function

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.

Link to this function

start_link(args)