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
@type hostname() :: :inet.socket_address() | :inet.hostname()
Shorthand type for socket.
@type port_number() :: :inet.port_number()
Shorthand type for port number.
@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
@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.
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.
@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.
@spec start_link([any()]) :: GenServer.on_start()