anchor.diff:  	       end,
       ok = sendfile_send(SendTl).
   
  +t_sendfile_sendafter(Config) ->
  +    Filename = proplists:get_value(small_file, Config),
  +
  +    Send = fun(Sock) ->
  +		   {Size, Data} = sendfile_file_info(Filename),
  +		   {ok, Size} = gen_tcp:sendfile(Filename, Sock),
  +		   ok = gen_tcp:send(Sock, <<2>>),
  +		   <<Data/binary,2>>
  +	   end,
  +
  +    ok = sendfile_send(Send).
  +
  +t_sendfile_recvafter(Config) ->
  +    Filename = proplists:get_value(small_file, Config),
  +
  +    Send = fun(Sock) ->
  +		   {Size, Data} = sendfile_file_info(Filename),
  +		   {ok, Size} = gen_tcp:sendfile(Filename, Sock),
  +		   ok = gen_tcp:send(Sock, <<1>>),
  +		   {ok,<<1>>} = gen_tcp:recv(Sock, 1),
  +		   <<Data/binary,1>>
  +	   end,
  +
  +    ok = sendfile_send(Send).
  +
  +t_sendfile_sendduring(Config) ->
  +    Filename = proplists:get_value(big_file, Config),
  +
  +    Send = fun(Sock) ->
  +		   {ok, #file_info{size = Size}} =
  +		       file:read_file_info(Filename),
  +		   spawn_link(fun() ->
  +				      timer:sleep(10),
  +				      ok = gen_tcp:send(Sock, <<2>>)
  +			      end),
  +		   {ok, Size} = gen_tcp:sendfile(Filename, Sock),
  +		   Size+1
  +	   end,
  +
  +    ok = sendfile_send("localhost", Send, 0).
  +
  +t_sendfile_recvduring(Config) ->
  +    Filename = proplists:get_value(big_file, Config),
  +
  +    Send = fun(Sock) ->
  +		   {ok, #file_info{size = Size}} =
  +		       file:read_file_info(Filename),
  +		   spawn_link(fun() ->
  +				      timer:sleep(10),
  +				      ok = gen_tcp:send(Sock, <<1>>),
  +				      {ok,<<1>>} = gen_tcp:recv(Sock, 1)
  +			      end),
  +		   {ok, Size} = gen_tcp:sendfile(Filename, Sock),
  +		   timer:sleep(1000),
  +		   Size+1
  +	   end,
  +
  +    ok = sendfile_send("localhost", Send, 0).
   
   %% TODO: consolidate tests and reduce code
   sendfile_send(Send) ->
  
positive.code: 
  sendfile_server(ClientPid, Orig) ->
      {ok, LSock} = gen_tcp:listen(0, [binary, {packet, 0},
  					   {active, false},
  					   {reuseaddr, true}]),
      {ok, Port} = inet:port(LSock),
      ClientPid ! {server, Port},
      {ok, Sock} = gen_tcp:accept(LSock),
      {ok, Bin} = sendfile_do_recv(Sock, Orig),
      ok = gen_tcp:close(Sock),
      ClientPid ! {ok, Bin}.
  
  -define(SENDFILE_TIMEOUT, 10000).
  %% f(),{ok, S} = gen_tcp:connect("localhost",7890,[binary]),gen_tcp:sendfile("/ldisk/lukas/otp/sendfiletest.dat",S).
  sendfile_do_recv(Sock, Bs) ->
      case gen_tcp:recv(Sock, 0, ?SENDFILE_TIMEOUT) of
  	{ok, B} when is_list(Bs) ->
  	    sendfile_do_recv(Sock, [B|Bs]);
  	{error, closed} when is_list(Bs) ->
  	    {ok, iolist_to_binary(lists:reverse(Bs))};
  	{ok, B} when is_integer(Bs) ->
  	    sendfile_do_recv(Sock, byte_size(B) + Bs);
  	{error, closed} when is_integer(Bs) ->
  	    {ok, Bs}
      end.
  
  sendfile_file_info(File) ->
  
negative.code: %     ,t_sendfile_hdtl
       ,t_sendfile_partial
       ,t_sendfile_offset
       ,t_sendfile_sendafter
       ,t_sendfile_recvafter
       ,t_sendfile_sendduring
       ,t_sendfile_recvduring
      ].
  %    [t_sendfile_big].
  %    [t_sendfile_small].
  