anchor.diff:      exit(error)
     end.
   
  +
   engage_backend(ClientSock, RequestPid, Hostname, Req, {ok, #backend{host = Host, port = Port} = Backend}) ->
     SockOpts = [  binary, 
                   {nodelay, true},
  
positive.code:   gen_tcp:close(ClientSock),
    exit(error).
  
  % Handle all the proxy here
  proxy_loop(#state{client_socket = CSock, server_socket = SSock} = State) ->
    receive
  	  {tcp, CSock, Data} ->
  
negative.code:   	Msg ->
  	    ?LOG(info, "~s:proxy_loop: unexpectedly recieved ~w\n", [?MODULE, Msg]),
  	    proxy_loop(State)
    % If there is no activity for 2 minutes and the socket has not already closed, 
    % we'll assume that the connection is tired and should close, so we'll close it
    after 120000 ->
      ?LOG(info, "Terminating open proxy connection because of timeout", []),
      terminate(normal, State)
    end.
  
  % Close the connection.
  % First, fetch the stats on the sockets and the elapsed_time for the bckend activity
  % and notify the event chains of the closing stats. This also closes the stats activity for 
  % this backend. Finally, close the two sockets and leave the process. This way we can be assured
  % that the process closes itself.
  terminate(Reason, #state{server_socket = SSock, client_socket = CSock, start_time = STime, backend = Backend} = _State) ->
    StatsProplist1 = [{elapsed_time, date_util:now_to_seconds() - STime}],
    StatsProplist = case inet:getstat(CSock) of
  