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

Paul Oliver puzza007@REDACTED
Mon Nov 24 23:28:10 CET 2008


On Mon, Nov 24, 2008 at 10:18 PM, Matthias Lang <matthias@REDACTED>wrote:

> 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
>

Hi Matt,

Ah yes.  Thanks for pointing that out!  Yes, seems fine now:

1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection,
start}}, {name, badger}, {port, 8888}]).
{ok,<0.32.0>}
2> {ok, Sock} = gen_tcp:connect('127.0.0.1', 8888,  [binary, {packet, line},
{nodelay, true}], 3000000).
{ok,#Port<0.496>}
3> Sock.
#Port<0.496>
4> gen_tcp:controlling_process(Sock, self()).
ok
5>

Back to the drawing board!

Cheers,
Paul.

>
> >
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081124/0586a810/attachment.htm>


More information about the erlang-questions mailing list