Tcp.Listener (gt_bridge v0.17.1)

Copy Markdown View Source

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

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.

t()

@type t() :: %Tcp.Listener{
  host: hostname() | 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

  • :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.

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()