[erlang-questions] Starting an echo web server from (bash) shell!

zabrane Mikael zabrane3@REDACTED
Tue Nov 2 00:17:45 CET 2010


Hi Ahmed,

Following your suggestion, I removed the "catch" and print out the error with:
io:format("Accept failed with error: ~p~n", [Error]).

I got:
Accept failed with error: closed

These are my socket options:
-define(SOCK_TCP_PORT, 8888).
-define(SOCK_TCP_OPTS, [binary,
                   {nodelay,   true},
                   {active,    false},
                   {packet,    http_bin},
                   {reuseaddr, true}]).

Hope this help.

-- 
Regards
Zabrane

2010/11/2 Ahmed Omar <spawn.think@REDACTED>:
> I would suggest you change the code to reveal the original error that you
> got
> so for Example could you raise the error that you get?
> or remove the catch and change the other case clause to {error, Error} and
> print out that Error?
> {error, Error}->
>        io:format("~p~n", [Error])
> end.
>
>
> On Mon, Nov 1, 2010 at 11:09 PM, zabrane Mikael <zabrane3@REDACTED> wrote:
>>
>> Hi list,
>>
>> I'm facing a strange problem when trying to start my very basic echo
>> web server from (bash) shell.
>>
>> It doesn't work when I try to run it from (bash) shell with an error
>> in "gen_tcp:accept/1" call:
>> $ erl -s bews
>>
>>
>> But it works fine when I run it from the Erlang shell:
>> $ erl
>> 1> bews:start().
>>
>> The server is simply listening on socket 8888 and echo back what it gets:
>> ...
>> case catch gen_tcp:accept(ListenSocket) of
>>        {ok, Sock} ->
>>               ...
>>        _ ->
>>           exit({error,accept_failed})
>> end.
>>
>> Any advices please?
>>
>> N.B: I'm under OSX Snow Leopard, Erlang R14B (erts-5.8.1)
>>
>> --
>> Regards
>> Zabrane
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>>
>
>
>
> --
> Best Regards,
> - Ahmed Omar
> http://nl.linkedin.com/in/adiaa
> Follow me on twitter
> @spawn_think
>


More information about the erlang-questions mailing list