[erlang-questions] inet_db:lookup_socket/1 failing for gen_tcp:controlling_process with mochiweb socket server

Matthias Lang matthias@REDACTED
Mon Nov 24 23:18:25 CET 2008


On Monday, November 24, Paul Oliver wrote:
> Hi all,
> 
> I have a curious bug that I've tracked down to a call to
> gen_tcp:controlling_process.  From the stack trace (simple example
> reproduced below) it seems that the port in question definitely exists, but
> the call to inet_db:lookup fails.  Has anyone seen this before or got any
> advice?

This seems too obvious to be your real problem, but just in case, 
the second command isn't handling the return correctly. You probably
meant:

{ok, Sock} = gen_tcp:connect(...

Matt

> 
> Thanks!
> Paul.
> 
> Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0]
> [kernel-poll:false]
> 
> Eshell V5.6.5  (abort with ^G)
> 1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection,
> start}}, {name, badger}, {port, 8888}]).
> {ok,<0.32.0>}
> 2> Sock = gen_tcp:connect('127.0.0.1', 8888,  [binary, {packet, line},
> {nodelay, true}], 3000000).
> {ok,#Port<0.496>}
> 3> gen_tcp:controlling_process(Sock, self()).
> 
> =ERROR REPORT==== 24-Nov-2008::20:59:12 ===
> ** Generic server badger terminating
> ** Last message in was {'EXIT',<0.30.0>,
>                            {function_clause,
>                                [{inet_db,lookup_socket,[{ok,#Port<0.496>}]},
>                                 {gen_tcp,controlling_process,2},
>                                 {erl_eval,do_apply,5},
>                                 {shell,exprs,6},
>                                 {shell,eval_exprs,6},
>                                 {shell,eval_loop,3}]}}
> ** When Server state == {mochiweb_socket_server,8888,
>                             {connection,start},
>                             {local,badger},
>                             2047,
>                             {127,0,0,1},
>                             #Port<0.488>,<0.37.0>,30}
> ** Reason for termination ==
> ** {function_clause,[{inet_db,lookup_socket,[{ok,#Port<0.496>}]},
>                      {gen_tcp,controlling_process,2},
>                      {erl_eval,do_apply,5},
>                      {shell,exprs,6},
>                      {shell,eval_exprs,6},
>                      {shell,eval_loop,3}]}
> ** exception exit: function_clause
>      in function  inet_db:lookup_socket/1
>         called as inet_db:lookup_socket({ok,#Port<0.496>})
>      in call from gen_tcp:controlling_process/2
> 4>

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list