[erlang-questions] gen_tcp:recv and hairloss
Kevin
q2h46uw02@REDACTED
Mon Nov 10 21:39:30 CET 2008
> .... this and see what happens:
>
> ....() ->
> {ok,LS} = gen_tcp:listen(7000,[binary,{active,false}]),
> {ok,Sock} = gen_tcp:accept(LS),
> spawn(fun() -> do_recv(Sock) end),
> spawn(fun() -> do_recv(Sock) end),
> ok.
>
>
> do_recv(Socket) ->
> io:format("Recv: ~p~n", [ gen_tcp:recv(Socket,0)]).
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
Point taken. I solved my problem by simply embracing
gen_fsm:sync_send_event, which I was probably
conceptually visualizing when I was using gen_fsm:send_event.
A lot of advice I got was to use gen_tcp:controlling_process, but
doesn't my success with passing a socket
and reading in a Fsm, as well as the example above, show thats its a
common myth that you need to use controlling_process if you
wish to use gen_tcp:recv in a process that didn't accept the socket in
the first place? I believe you only need to use
controlling_process if you want the socket data sent as a erlang message
to the process, and for that to happen it has to be {active, true}.
More information about the erlang-questions
mailing list