anchor.diff:          {connected, Owner} when Owner /= self() ->
               {error, not_owner};
           undefined ->
  -            {error, einval};
  +            {error, closed};
           _ ->
               {ok, Opts} = getopts(Sock, [active,type]),
               {active,A} = lists:keyfind(active,1,Opts),
  
positive.code: recv(Sock, Timeout) when is_port(Sock) ->
      Ref = make_ref(),
      Bin = term_to_binary(Ref),
      case binary_to_term(port_control(Sock, ?ENM_RECV, Bin)) of
          {Ref, wait} ->
              receive
                  {Ref, Reply} when is_tuple(Reply) ->
  
negative.code:          end,
      ok.
  
  close_test_() ->
      {setup,
       fun start_link/0,
       fun(_) -> stop() end,
       [fun close_twice/0,
        fun close_send/0,
        fun close_recv/0,
        fun close_bind/0,
        fun close_connect/0,
        fun close_shutdown/0,
        fun close_getopts/0,
        fun close_setopts/0,
        fun close_ctrlproc/0]}.
  
  close_twice() ->
      {ok,Sock} = enm:pair(),
      %% verify multiple calls to close just return ok
      ok = enm:close(Sock),
      ok = enm:close(Sock),
      ok.
  
  close_send() ->
      {ok,Sock} = enm:pair(),
      ok = enm:close(Sock),
      {error, closed} = enm:send(Sock, "foo"),
      ok.
  
  close_recv() ->
      {ok,Sock} = enm:pair(),
      ok = enm:close(Sock),
      {error, closed} = enm:recv(Sock),
      ok.
  
  close_bind() ->
      {ok,Sock} = enm:pair(),
      ok = enm:close(Sock),
      {error, closed} = enm:bind(Sock, "inproc://foo"),
      ok.
  
  close_connect() ->
      {ok,Sock} = enm:pair(),
      ok = enm:close(Sock),
      {error, closed} = enm:connect(Sock, "inproc://foo"),
      ok.
  
  close_shutdown() ->
      {ok,Sock} = enm:pair(),
      {ok,Id} = enm:bind(Sock, "inproc://foo"),
      ok = enm:close(Sock),
      {error, closed} = enm:shutdown(Sock, Id),
      ok.
  
  close_getopts() ->
      {ok,Sock} = enm:pair(),
      ok = enm:close(Sock),
      {error, closed} = enm:getopts(Sock, [active]),
      ok.
  
  close_setopts() ->
      {ok,Sock} = enm:pair(),
      ok = enm:close(Sock),
      {error, closed} = enm:setopts(Sock, [{active,false}]),
      ok.
  
  close_ctrlproc() ->
      {ok,Sock} = enm:pair(),
      ok = enm:close(Sock),
      {error, closed} = enm:controlling_process(Sock, self()),
      ok.
  
  -endif.
  