anchor.diff:  	  linked=no
   	 }).
   
  +-record(recv, {
  +	  msg_stack=[],		%% First-in-last-out stack of received frames (messages)
  +	  frame = <<>>,		%% The current frame
  +
  +	  parsed,		%% undefined | request record() | response record()
  +	  body_offset,		%% undefined | integer(), the start position of the body in 'frame'
  +	  body_length,		%% undefined | integer(), the content length of the message
  +	  bytes_left,		%% undefined | integer(), number of bytes left on this frame -
  +				%% redundant data (we could always calculate it) but it is easier this way
  +	  origin_str		%% string(), used when logging receved frames
  +	 }).
  +
  +%%--------------------------------------------------------------------
  +%% Macros
  +%%--------------------------------------------------------------------
  +-define(CR, 16#0D).
  +-define(LF, 16#0A).
  +
   %%====================================================================
   %% External functions
   %%====================================================================
  
positive.code: %% Returns : void()
  %%--------------------------------------------------------------------
  start_link(SocketModule, Socket, Local, Remote, SipSocket) ->
      State = #state{socketmodule=SocketModule, socket=Socket, parent=self(), local=Local, remote=Remote, sipsocket=SipSocket},
      Pid = spawn_link(?MODULE, recv_loop, [State, []]),
      Pid.
  
  %%====================================================================
  
negative.code: %%% Author  : Fredrik Thulin <ft@it.su.se>
  %%% Descrip.: TCP receiver does blocking read on a single socket and
  %%%           signals parent when a complete SIP request/response has
  %%%           been received. If we encounter something we can't handle
  %%%           we just close the socket. There is no way to know if we
  %%%           are in or out of sync with the remote end if we have
  %%%           encountered something not perfectly legal.
  %%%
  %%%           tcp_receiver processes are just the blocking-read shadow
  %%%           of tcp_connection processes. We consider the
  %%%           tcp_connection process the 'real owner' of the open
  %%%           socket, so we never for example close the sockets
  %%%           ourselves - instead we signal the tcp_connection process
  %%%           (our State#state.parent) to close it, and then we just
  %%%           terminate. This is not really true for SSL sockets
  %%%           though, since the ssl module should send received data
  %%%           to this process we are also the owner of SSL sockets.
  %%%
  %%%           Signals we send to our parent :
  %%%
  %%%           {recv_sipmsg, R} - we have received a complete SIP
  %%%                              message and parsed it into a request
  %%%                              or response record()
  %%%           {close, self()}  - close the socket, please
  %%%           {connection_closed, self()} - the other end has closed
  %%%                                         the socket
  %%%
  %%%           Signals we honor (SSL sockets only) :
  %%%
  %%%           {quit_receiver, Parent} - we should close the socket
  %%%
  %%% Created : 15 Mar 2004 by Fredrik Thulin <ft@it.su.se>
  %%%-------------------------------------------------------------------
  
  -module(tcp_receiver).
  -compile(export_all).
  
  %%--------------------------------------------------------------------
  %% External exports
  %%--------------------------------------------------------------------
  -export([start_link/5,
  	 test/0]).
  
  %%--------------------------------------------------------------------
  %% Internal exports
  