[erlang-questions] gen_sctp:connect() always fail

Raimo Niskanen raimo+erlang-questions@REDACTED
Mon Nov 14 14:43:23 CET 2011


On Fri, Nov 11, 2011 at 03:25:37PM +0100, Victoria Pometsko wrote:
> Hi,
> 
> *)The server side code is:
> 
> The following is just an example from gen_sctp manual, and it works just fine (for the case when client socket could not be connected)
> 
> server() ->
>       server(any, 2006).
>   
>   server([Host,Port]) when is_list(Host), is_list(Port) ->
>       {ok, #hostent{h_addr_list = [IP|_]}} = inet:gethostbyname(Host),
>       io:format("~w -> ~w~n", [Host, IP]),
>       server([IP, list_to_integer(Port)]).
>   
>   server(IP, Port) when is_tuple(IP) orelse IP == any orelse IP == loopback,
>                         is_integer(Port) ->
>       {ok,S} = gen_sctp:open(Port, [{recbuf,65536}, {ip,IP}]),
>       io:format("Listening on ~w:~w. ~w~n", [IP,Port,S]),
>       ok     = gen_sctp:listen(S, true),
>       server_loop(S).
>   
>   server_loop(S) ->
>       case gen_sctp:recv(S) of
>       {error, Error} ->
>           io:format("SCTP RECV ERROR: ~p~n", [Error]);
>       Data ->
>           io:format("Received: ~p~n", [Data])
>       end,
>       server_loop(S).         
> 
> *)
> Yeah, I read that it was tested on SLES 10 SP1, 
> (as I wrote I've got not exactly the same system)

Well you have SLED 10 SP 1 which is very close and since
gen_sctp:open/2 does not badarg you have the SCTP libraries
so it should work.

> 
> So the question is still exists:
> Can I have such results because of the environment?

Of course. Or because how you start the server.

1) If you start the server with server({127,0,0,1}, 2006) and 
   on the client side use gen_sctp:connect(S, {127,0,0,1}, 6666, [])
   I think you would get this error.
2) server("myhostname", 6666) and gen_sctp:connect(S, {127,0,0,1}, 6666, [])
   when "myhostname" resolves to the external IP address would also do this.
3) A firewall may be causing this.

The error you describe corresponds to ECONNREFUSED in TCP, so it can be
any of some dozen reasons. So can you please tell the list exactly what
you do, try to use just kernel/stdlib calls from the shell, and exactly
what you get from them, to provoke the error.

> 
> 
> 
> BR,
> Victoria
> 
> -----Original Message-----
> From: Raimo Niskanen [mailto:raimo+erlang-questions@REDACTED] 
> Sent: den 10 november 2011 15:05
> To: Victoria Pometsko; erlang-questions@REDACTED
> Subject: Re: [erlang-questions] gen_sctp:connect() always fail
> 
> On Thu, Nov 10, 2011 at 02:08:35PM +0100, Victoria Pometsko wrote:
> > 
> > Hello,
> > 
> > I'm trying  to work with sctp sockets using gen_sctp module, and faced the following problem:
> > 
> > Client side code:
> > 
> > {ok, S}=gen_sctp:open(5555, [{ip,{127,0,0,1}},  binary, inet, {active, true}, {reuseaddr, true}]).
> > %% res : {ok,#Port<0.5931>}
> > 
> > gen_sctp:connect(S, {127,0,0,1}, 6666,[]).
> > %% res : {error,{sctp_assoc_change,cant_assoc,0,0,0,0}}
> 
> What is the server side code?
> Is there a gen_sctp:listen missing?
> 
> > 
> > (if I'm using connect_init(), recv()  result is the same)
> > 
> > 
> > The thing that I also do not understand why example code from  
> > http://www.erlang.org/doc/man/gen_sctp.html
> > Is also not working for me:
> > 
> >   client(localhost, 2006) when is_integer(Port) ->
> >       {ok,S}     = gen_sctp:open(),
> >       {ok,Assoc} = gen_sctp:connect(S, Host, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]) ....
> >         %% It fails with: 
> > {error,{sctp_assoc_change,cant_assoc,0,0,0,0}}
> > ?
> > 
> > 
> > The environment is:
> > SUSE Linux Enterprise Desktop 10 (i586) VERSION = 10 PATCHLEVEL = 1 
> > LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-ia32:core-3.0-ia32"
> > 
> > 
> > I read at http://www.erlang.org/doc/man/gen_sctp.html that gen_sctp implementation has only been tested on several Linux versions.
> > 
> > So the questions are:
> > Can I have such results because of the environment?
> > If no, then how do you think, what am I missing?
> 
> It should work on SLES 10 SP1.
> 
> > 
> > 
> > 
> > With best regards,
> > Vic
> > 
> > 
> 
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> 
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list