anchor.diff:  	 <<CD:16>> = <<C,D>>,
   	 {0, 0, 0, 0, 0, 16#ffff, AB, CD}
        end || {A,B,C,D} <- InetAddrs].
  -
  -f(F, A) ->
  -    lists:flatten(io_lib:format(F, A)).
   
   do_open_and_connect(ServerAddresses, AddressToConnectTo) ->
       Fun = fun (_, _, _, _, _, _) -> ok end,
  
positive.code: timestamp() ->
      erlang:monotonic_time().
  
  formated_timestamp() ->
      format_timestamp(os:timestamp()).
  
  
negative.code:     ok = gen_sctp:close(S1),
      ok.
  
  
  %% There is no way to know how many addresses this host has,
  %% and if there is "too many" (more then N = 3), then the
  %% socket may already be passive. In this case the send-
  %% loop will fail.
  %% So, if we get a passive-message here, we just give up (=skip).
  active_n_flush_connect_msgs(Sock) ->
      %% This seems only to be needed on certain platforms
      active_n_flush_connect_msgs(os:type(), Sock).
  
  active_n_flush_connect_msgs(_, Sock) ->
      do_active_n_flush_connect_msgs(Sock).
  %% active_n_flush_connect_msgs({unix, freebsd}, Sock) ->
  %%     do_active_n_flush_connect_msgs(Sock);
  %% active_n_flush_connect_msgs(_, _) ->
  %%     ok.
  
  do_active_n_flush_connect_msgs(Sock) ->
      receive
          {sctp_passive, Sock} ->
              p("connect-flush-loop -> premature passive"),
              skip("Too many addresses (premature passive)");
  
          {sctp, Sock,
           _FromIP, _FromPort,
           {[], #sctp_assoc_change{state = comm_up}}} ->
              p("connect-flush-loop -> "
                "connect message discard - assoc change : comm-up"),
              ok = inet:setopts(Sock, [{active, 1}]),
              do_active_n_flush_connect_msgs(Sock);
  
          {sctp, Sock,
           _FromIP, _FromPort,
           {[], #sctp_paddr_change{state    = addr_confirmed,
                                   addr     = Addr,
                                   error    = Error,
                                   assoc_id = AID}}} ->
              p("connect-flush-loop -> "
                "connect message discard - paddr change : addr-confirmed:"
                "~n   Addr:    ~p"
                "~n   Error:   ~p"
                "~n   AssocID: ~p", [Addr, Error, AID]),
              ok = inet:setopts(Sock, [{active, 1}]),
              do_active_n_flush_connect_msgs(Sock)
  
      after 5000 ->
              ok
      end.
              
  active_n_send_loop(Count, SrcSock, SndAssoc, DstSock) ->
      active_n_send_loop(0, Count, SrcSock, SndAssoc, DstSock).
  
  active_n_send_loop(Count, Count, _SndSock, _SndAssoc, RcvSock) ->
      p("send-loop -> we are done - wait for passive"),
      receive
          {sctp_passive, RcvSock} ->
              p("received passive"),
              ok
      after
          5000 ->
              p("UNEXPECTED TIMEOUT: "
                "~n   Message Queue:    ~p"
                "~n   Active:           ~p",
                [process_info(self(), messages),
                 inet:getopts(RcvSock, [active])]),
              exit({error, timeout})
      end;
  
  active_n_send_loop(Sent, Count, SndSock, SndAssoc, RcvSock) ->
      Msg = list_to_binary("message " ++ integer_to_list(Sent+1)),
      p("send-loop(~w,~w) -> send message (on ~p)", [Sent, Count, SndSock]),
      ok = gen_sctp:send(SndSock, SndAssoc, 0, Msg),
      receive
          {sctp, RcvSock, FromIP, FromPort, {[SR], Msg}}
          when is_record(SR, sctp_sndrcvinfo) ->
              p("send-loop(~w,~w) -> "
                "recv (expected) data message (on ~p):"
                "~n   Msg:  ~p"
                "~n   From: ~p, ~p",
                [Sent, Count,
                 RcvSock, Msg, FromIP, FromPort]),
              active_n_send_loop(Sent+1, Count, SndSock, SndAssoc, RcvSock);
          
          {sctp, RcvSock, _FromIP, _FromPort, {_AncData, _Data}} ->
              %% ignore non-data messages
              %% we should not get any here because of the flush loop,
              %% but just in case...
              p("send-loop(~w,~w) -> "
                "ignore non-data messages (on ~p):"
                "~n   From:    ~p:~p"
                "~n   AncData: ~p"
                "~n   Data:    ~p",
                [Sent, Count,
                 RcvSock, _FromIP, _FromPort, _AncData, _Data]),
              
              %% It may be too late to update here,
              %% the socket may already have gone passive 
              %% and generated a passive message!
              
              ok = inet:setopts(RcvSock, [{active, 1}]),
  
              active_n_send_loop(Sent, Count, SndSock, SndAssoc, RcvSock);
          
          Other ->
              p("send-loop(~w,~w) -> "
                "UNEXPECTED: "
                "~n   Other:     ~p"
                "~n   Send Sock: ~p"
                "~n   Recv Sock: ~p", [Sent, Count,
                                       Other, SndSock, RcvSock]),
              exit({unexpected, Other})
      after
          5000 ->
              exit({error,timeout})
      end.
      
  %% Hello world stream socket.
  basic_stream(Config) when is_list(Config) ->
      {ok,S} = gen_sctp:open([{type,stream}]),
  