Recieve packet from socket in Erlang active mode with ASCII packet size header

zxq9 zxq9@REDACTED
Tue Jan 5 15:55:10 CET 2021


On 2021/01/05 23:51, zxq9 wrote:
> Hi, George.
> 
> Reply is below.

Ah... in the previous response I forgot to mention what was going on in 
the state record (the ubiquitous  #s{}...). It would be something like:

-record(s,
         {ssl             :: term(), % whatever_type_ssl_is(),
          protocol        :: term(), % probably_an_atom(),
          socket          :: gen_tcp:socket() | ssl:sslsocket(),
          left     = none :: none | pos_integer(),
          acc      = none :: none | binary()}).


Or whatever you need to have in there. Once a tuple grows past about 3 
or 4 members I tend to make them records except for special 
circumstances (and nearly always in the case of a state record).

-Craig


More information about the erlang-questions mailing list