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

Ladislav Lenart lenartlad@REDACTED
Thu Jul 12 16:51:22 CEST 2007


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




More information about the erlang-questions mailing list