anchor.diff:     
   %% Test the send_timeout socket option.
   send_timeout(Config) when is_list(Config) ->
  +    Dir = filename:dirname(code:which(?MODULE)),
  +    {ok,RNode} = test_server:start_node(?UNIQ_NODE_NAME, slave,
  +					[{args,"-pa " ++ Dir}]),
  +
       %% Basic
  -    BasicFun =
  -	fun(AutoClose) ->
  -	     {Loop,A,RNode} = setup_timeout_sink(1000, AutoClose),
  -	     {error,timeout} =
  -		 Loop(fun() ->
  -			      Res = gen_tcp:send(A,<<1:10000>>),
  -			      %%erlang:display(Res),
  -			      Res
  -		      end),
  -	     %% Check that the socket is not busy/closed...
  -	     Error = after_send_timeout(AutoClose),
  -	     {error,Error} = gen_tcp:send(A,<<"Hej">>),
  -	     test_server:stop_node(RNode)
  -	end,
  -    BasicFun(false),
  -    BasicFun(true),
  -    %% Check timeout length
  +    send_timeout_basic(false, RNode),
  +    send_timeout_basic(true, RNode),
  +
  +    BinData = <<1:10000>>,
  +
  +    %% Check timeout length.
       Self = self(),
       Pid = spawn(fun() ->
  -                        {Loop,A,RNode} = setup_timeout_sink(1000, true),
  -                        {error,timeout} = Loop(fun() ->
  -                                     Res = gen_tcp:send(A,<<1:10000>>),
  -                                     %%erlang:display(Res),
  -                                     Self ! Res,
  -                                     Res
  -                             end),
  -                        test_server:stop_node(RNode)
  +                        A = setup_timeout_sink(RNode, 1000, true),
  +			Send = fun() ->
  +				       Res = gen_tcp:send(A, BinData),
  +				       Self ! Res,
  +				       Res
  +			       end,
  +			{error,timeout} = timeout_sink_loop(Send)
   	      end),
       Diff = get_max_diff(),
       io:format("Max time for send: ~p~n",[Diff]),
       true = (Diff > 500) and (Diff < 1500),
  -    %% Let test_server slave die...
  +
  +    %% Wait for the process to die.
       Mon = erlang:monitor(process, Pid),
       receive {'DOWN',Mon,process,Pid,_} -> ok end,
  +
       %% Check that parallell writers do not hang forever
  -    ParaFun =
  -	fun(AutoClose) ->
  -		{Loop,A,RNode} = setup_timeout_sink(1000, AutoClose),
  -		SenderFun = fun() ->
  -				    {error,Error} =
  -					Loop(fun() ->
  -						     gen_tcp:send(A, <<1:10000>>)
  -					     end),
  -				    Self ! {error,Error}
  -			    end,
  -		spawn_link(SenderFun),
  -		spawn_link(SenderFun),
  -                receive
  -                    {error,timeout} -> ok
  -                after 10000 ->
  -                          exit(timeout)
  -                end,
  -		NextErr = after_send_timeout(AutoClose),
  -                receive
  -                    {error,NextErr} -> ok
  -                after 10000 ->
  -                          exit(timeout)
  -                end,
  -		{error,NextErr} = gen_tcp:send(A,<<"Hej">>),
  -		test_server:stop_node(RNode)
  -	end,
  -    ParaFun(false),
  -    ParaFun(true),
  +    send_timeout_para(false, RNode),
  +    send_timeout_para(true, RNode),
  +
  +    test_server:stop_node(RNode),
  +
  +    ok.
  +
  +send_timeout_basic(AutoClose, RNode) ->
  +    BinData = <<1:10000>>,
  +
  +    A = setup_timeout_sink(RNode, 1000, AutoClose),
  +    Send = fun() -> gen_tcp:send(A, BinData) end,
  +    {error,timeout} = timeout_sink_loop(Send),
  +
  +    %% Check that the socket is not busy/closed...
  +    Error = after_send_timeout(AutoClose),
  +    {error,Error} = gen_tcp:send(A, <<"Hej">>),
  +    ok.
  +
  +send_timeout_para(AutoClose, RNode) ->
  +    BinData = <<1:10000>>,
  +
  +    A = setup_timeout_sink(RNode, 1000, AutoClose),
  +    Self = self(),
  +    SenderFun = fun() ->
  +			Send = fun() -> gen_tcp:send(A, BinData) end,
  +			{error,Error} = timeout_sink_loop(Send),
  +			Self ! {error,Error}
  +		end,
  +    spawn_link(SenderFun),
  +    spawn_link(SenderFun),
  +
  +    receive
  +	{error,timeout} -> ok
  +    after 10000 ->
  +	    exit(timeout)
  +    end,
  +
  +    NextErr = after_send_timeout(AutoClose),
  +    receive
  +	{error,NextErr} -> ok
  +    after 10000 ->
  +	    exit(timeout)
  +    end,
  +
  +    {error,NextErr} = gen_tcp:send(A, <<"Hej">>),
       ok.
   
   mad_sender(S) ->
  
positive.code:     {ok,A} = gen_tcp:accept(L),
      gen_tcp:send(A,"Hello"),
      {ok, "Hello"} = Remote(fun() -> gen_tcp:recv(C,0) end),
      Loop2 = fun(_,_,0) ->
  		    {failure, timeout};
  	       (L2,F2,N) ->
  		    Ret = F2(),
  		    io:format("~p~n",[Ret]),
  		    case Ret of
  			ok -> receive after 1 -> ok end,
  			      L2(L2,F2,N-1);
  			Other -> Other
  		    end
  	    end,
      Loop = fun(F3) ->  Loop2(Loop2,F3,1000) end,
      {Loop,A,R}.
  
  setup_active_timeout_sink(Timeout, AutoClose) ->
      Dir = filename:dirname(code:which(?MODULE)),
      {ok,R} = test_server:start_node(?UNIQ_NODE_NAME, slave,
                                      [{args,"-pa " ++ Dir}]),
      Host = get_hostname(node()),
      {ok, L} = gen_tcp:listen(0, [binary,{active,false},{packet,0},{nodelay, true},{keepalive, true},
  				 {send_timeout,Timeout},
  				 {send_timeout_close,AutoClose}]),
      Fun = fun(F) ->
  		  receive
  		      {From,X} when is_function(X) ->
  			  From ! {self(),X()}, F(F);
  		      die -> ok
  		  end
  	  end,
      Pid =  rpc:call(R,erlang,spawn,[fun() -> Fun(Fun) end]),
      {ok, Port} = inet:port(L),
      Remote = fun(Fu) ->
  		     Pid ! {self(), Fu},
  
negative.code:     test_server:stop_node(R),
      {Loop,A}.
      
  setup_timeout_sink(RNode, Timeout, AutoClose) ->
      Host = get_hostname(node()),
      {ok, L} = gen_tcp:listen(0, [{active,false},{packet,2},
  				 {send_timeout,Timeout},
  