Tcp.Connection (gt_bridge v0.19.2)

Copy Markdown View Source

I serve one GT connection over a length-framed socket.

Requests and module events share my mailbox, which is the point: a reply is a frame carrying the id GT sent, an event is a frame with none, and GT tells them apart on arrival. One socket carries both directions, so there is no second connection for GT to lose.

I evaluate in a spawned task rather than inline: an eval may take as long as user code takes, and events queued behind a Process.sleep/1 would arrive late. Replies carry their id, so they may return in any order.

Summary

Types

t()

I am the state of a TCP connection.

Functions

Returns a specification to start this module under a supervisor.

Types

t()

@type t() :: %Tcp.Connection{socket: port() | nil}

I am the state of a TCP connection.

Fields

  • :socket - The socket of the connection.

Functions

child_spec(init_arg)

@spec child_spec([any()]) :: Supervisor.child_spec()

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(args)

@spec start_link([any()]) :: GenServer.on_start()