I am testing the following pattern in a GenServer:
def handle_info({:tcp, _, data}, s) do
# IO.puts "\nrx: \n#{Base.encode16(data)}\n"
extra = _proc_data(<<s.extra::binary, data::binary>>)
:inet.setopts(s.socket, active: :once)
{:noreply, %{s | extra: extra}}
end
There is a problem when data comes in fast, and i'm unable to update state before :inet.setopts(s.socket, active: :once)
releases new data
Must {:noreply, %{s | extra: extra}}
be the last line for handle_info
, or can I perform the :inet.setopts(s.socket, active: :once)
last?
Is there a better way to do this?