#Server, acceptor and handle client inputs
1 messages · Page 1 of 1 (latest)
You want to flip it:
acceptor_loop(LSock) -> % You do not need port there
{ok, Sock} = gen_tcp:accept(LSock),
spawn(fun() -> handle(Sock) end),
acceptor_loop(LSock).
handle(Sock) ->
{ok, Data} = gen_tcp:recv(Sock, 0),
% Do something with `Data`
handle(Sock). % If you want to listen for more messages