anchor.diff:  -import(io).
   -import(io_lib).
   -import(log).
  +-import(timer).
   
   -include("comm_layer.hrl").
   
  
positive.code: 	    loop(Socket, Address, Port)
      end.
  
  %% @spec new_connection(inet:ip_address(), int(), int()) -> inet:socket() | fail
  new_connection(Address, Port, MyPort) ->
      case gen_tcp:connect(Address, Port, [binary, {packet, 4}, {nodelay, true}, {active, once}, 
  					 {send_timeout, config:read(tcp_send_timeout)}], 
  			 config:read(tcp_connect_timeout)) of
          {ok, Socket} ->
                                                  % send end point data
  	    case inet:sockname(Socket) of
  		{ok, {MyAddress, _MyPort}} ->
  	            gen_tcp:send(Socket, term_to_binary({endpoint, MyAddress, MyPort})),
  		    case inet:peername(Socket) of
  			{ok, {RemoteIP, RemotePort}} ->
  		            gen_tcp:send(Socket, term_to_binary({youare, RemoteIP, RemotePort})),
  		            Socket;
  			{error, Reason} ->
  			   log:log(error,"[ CC ] reconnect to ~p because socket is ~p", [Address, Reason]),
  			    gen_tcp:close(Socket),
  	    		    new_connection(Address, Port, MyPort)
  		    end;
  		{error, Reason} ->
  		    log:log(error,"[ CC ] reconnect to ~p because socket is ~p", [Address, Reason]),
  		    gen_tcp:close(Socket),
  	            new_connection(Address, Port, MyPort)
  	    end;
          {error, Reason} ->
              log:log(error,"[ CC ] couldn't connect to ~p:~p (~p)", [Address, Port, Reason]),
  	    fail
      end.
      
  
negative.code: 
  send({Address, Port, Socket}, Pid, Message) ->
      BinaryMessage = term_to_binary({deliver, Pid, Message}),
      SendTimeout    = config:read(tcp_send_timeout),
      {Time, Result} = timer:tc(gen_tcp, send, [Socket, BinaryMessage]),
      if
  	Time > 1200 * SendTimeout ->
  	    log:log(error,"[ CC ] send to ~p took ~p: ~p", 
  		    [Address, Time, inet:getopts(Socket, [keep_alive, send_timeout])]);
  	true ->
  	    ok
      end,
      case Result of
  	ok ->
  	    ?LOG_MESSAGE(erlang:element(1, Message), byte_size(BinaryMessage)),
  	    ok;
  	{error, closed} ->
  	    comm_port:unregister_connection(Address, Port),
  	    close_connection(Socket);
  	{error, Reason} ->
  	    log:log(error,"[ CC ] couldn't send to ~p:~p (~p)", [Address, Port, Reason]),
  	    comm_port:unregister_connection(Address, Port),
  	    close_connection(Socket)
      end.
  
  loop(fail, Address, Port) ->
  