check_tcp_options.erl 461 B

12345678910111213141516
  1. -module(check_tcp_options).
  2. -behaviour(ranch_protocol).
  3. -export([start_link/3]).
  4. -export([init/3]).
  5. start_link(Ref, _, [{pid, TestPid}|TcpOptions]) ->
  6. Pid = spawn_link(?MODULE, init, [Ref, TestPid, TcpOptions]),
  7. {ok, Pid}.
  8. init(Ref, Pid, TcpOptions) ->
  9. {ok, Socket} = ranch:handshake(Ref),
  10. {ok, RealTcpOptions} = inet:getopts(Socket, [Key || {Key, _} <- TcpOptions]),
  11. true = TcpOptions =:= RealTcpOptions,
  12. Pid ! checked,
  13. receive after 2500 -> ok end.