[erlang-questions] [Q] prim_inet:async_accept and gen_tcp:send

Tony Rogvall tony@REDACTED
Thu Jul 12 17:21:41 CEST 2007


Reading the code for accept in the module inet_tcp.erl (in lib/kernel)
accept makes a call to inet_db:register_socket(S, ?MODULE).

you need to call it with ?MODULE replaced by the atom inet_tcp.

/Tony


On 12 jul 2007, at 16.51, Ladislav Lenart wrote:

> Hello,
>
> based on a previous thread about prim_inet:async_accept we tried to
> use it ourselves but the connection socket we get is unusable. To
> repeat do following in the erlang shell:
>
> $> {ok, Port} = gen_tcp:listen(6667, [list, {packet, line},  
> {active, false}]).
> {ok, #Port<0.70890>}
> $> {ok, Ref} = prim_inet:async_accept(P, -1).
> {ok, 0}
>
> Now telnet to localhost:6667 and continue:
>
> $> receive {inet_async, Port, Ref, {ok, Socket}} -> {ok, Socket} end.
> {ok, #Port<0.70891>}
>
> However evaluating gen_tcp:send(Socket, Data) crashes with
> {undef, [{undefined, send, [Socket, Data]}, ...]}
>
> We found out that problem is in gen_tcp:send/2 which
> in turn calls inet_db:lookup_socket(Socket) which calls
> erlang:port_get_data(Socket) which returns undefined
> (instead of inet_tcp?).
>
> Any clues to what we are doing wrong?
>
> Thanks,
>
> Ladislav Lenart
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list