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
Functions
Returns a specification to start this module under a supervisor.
Types
@type t() :: %Tcp.Connection{socket: port() | nil}
I am the state of a TCP connection.
Fields
:socket- The socket of the connection.
Functions
@spec child_spec([any()]) :: Supervisor.child_spec()
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link([any()]) :: GenServer.on_start()