[erlang-questions] Erlang listen port

Abdul Fattah Mahran <>
Sun Jan 16 15:19:17 CET 2011


Hi all,
    The problem is you are using a reserved port.

Thanks

On Sun, Jan 16, 2011 at 7:59 AM, shk <> wrote:

>
> Hello,
>
> I write simple pop3 server. I try to listen 110 port:
>
> -module(test).
>
> -export([listen/1]).
>
> -define(TCP_OPTIONS, [binary, {packet, 0}, {active, false}, {reuseaddr,
> true}]).
>
> % Call echo:listen(Port) to start the service.
> listen(Port) ->
>    case  gen_tcp:listen(Port, ?TCP_OPTIONS) of
>    {ok, LSocket} ->
>       accept(LSocket);
>    {error, Reason} ->
>            Reason
>    end.
>
> % Wait for incoming connections and spawn the echo loop when we get one.
> accept(LSocket) ->
>    {ok, Socket} = gen_tcp:accept(LSocket),
>    spawn(fun() -> loop(Socket) end),
>    accept(LSocket).
>
> % Echo back whatever data we receive on Socket.
> loop(Socket) ->
>    case gen_tcp:recv(Socket, 0) of
>        {ok, Data} ->
>            gen_tcp:send(Socket, Data),
>            loop(Socket);
>        {error, closed} ->
>            ok
>    end.
>
> I run this code in eshell:
> 1>test:listen(110).
> eacces
>
> What's wrong?
>
> Thank you.
>
> --
> View this message in context:
> http://erlang.2086793.n4.nabble.com/Erlang-listen-port-tp3219753p3219753.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


-- 
Thanks
Best Regards,
Abd El-Fattah Mahran


More information about the erlang-questions mailing list