Erlang listen port

shk kuleshovmail@REDACTED
Sun Jan 16 06:59:21 CET 2011


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.


More information about the erlang-questions mailing list