anchor.diff:          , csock = undefined
           , buf = <<>>
           , native_if_mod
  -        , is_secure = false
       }).
  +
  +-export([start_srv/2
  +        , stop_srv/0
  +		]).
   
   -export([start_link/1
           , init/1
  
positive.code:     % io:format("handle_cast ~p~n", [_Msg]),
  	{noreply, State}.
  
  handle_info({tcp, Sock, Data}, #state{buf=Buf, native_if_mod=_Mod, is_secure=_IsSec}=State) ->
      ok = inet:setopts(Sock, [{active, once}]),
      NewBuf = <<Buf/binary, Data/binary>>,
      Res = (catch binary_to_term(NewBuf)),
  
negative.code:                 {ok, LSock} ->
                      io:format("~p started imem_server ~p @ ~p~n", [self(), LSock, {ListenIf, ListenPort}]),
                      gen_server:cast(self(), accept),
                      true = erlang:register(?MODULE, self()),
                      {ok, #state{lsock=LSock}};
                  Reason ->
                      io:format("~p [ERROR] imem_server not started ~p~n", [self(), Reason]),
                      true = erlang:register(?MODULE, self()),
                      {ok, #state{}}
              end;
          _ ->
              {stop, disabled}
      end.
  
  handle_call({stop_listen}, _From, #state{lsock=LSock} = State) ->
      catch gen_server:close(LSock),
      io:format("~p imem tcp service stopped!~n", [self()]),
      {reply, ok, State};
  handle_call({start_listen, ListenIf, ListenPort}, _From, #state{lsock=LSock} = State) ->
      catch gen_server:close(LSock),
      case gen_tcp:listen(ListenPort, [binary, {packet, 0}, {active, false}, {ip, ListenIf}]) of
          {ok, LSock} ->
              io:format("~p started imem_server ~p @ ~p~n", [self(), LSock, {ListenIf, ListenPort}]),
              gen_server:cast(self(), accept),
              true = erlang:register(?MODULE, self()),
              {reply, ok, #state{lsock=LSock}};
          Reason ->
              io:format("~p [ERROR] imem_server not started ~p~n", [self(), Reason]),
              true = erlang:register(?MODULE, self()),
              {reply, Reason, State}
      end;
  handle_call(_Request, _From, State) ->
      % io:format("handle_call ~p~n", [_Request]),
      {reply, ok, State}.
  
  handle_cast(accept, #state{lsock=LSock}=State) ->
      {ok, Sock} = gen_tcp:accept(LSock),
      % io:format("accept conn ~p~n", [Sock]),
      {ok,Pid} = gen_server:start(?MODULE, [Sock, true], []),
      ok = gen_tcp:controlling_process(Sock, Pid),
      gen_server:cast(Pid, activate),
      gen_server:cast(self(), accept),
  