anchor.diff:          _ -> error
       end.
   
  -% handle tcp request
  +% concurrent tcp
   accept(LSock) ->
       {ok, Sock} = gen_tcp:accept(LSock),
       spawn(fun() -> accept(LSock) end),
  
positive.code: -define(TCP_OPTION, [binary, {active,false}, {packet,0}, {reuseaddr,true}]).
  
  start_link() ->
      case lists:member(?GRP_TABLE, ets:all()) of
          false -> ets:new(?GRP_TABLE, [bag, public, named_table]);
          true -> ok
      end,
      case lists:member(?REG_TABLE, ets:all()) of
          false -> ets:new(?REG_TABLE, [set, public, named_table]);
          true -> ok
      end,
      case gen_tcp:listen(?MEEQO_NAMESERVER_PORT, ?TCP_OPTION) of
          {ok, LSock} -> 
              spawn(fun() -> accept(LSock) end),
              Pid = spawn(fun() -> loop() end),
              true = register(?MODULE, Pid);
          {error, Reason} -> {error, Reason}
      end.
          
  % handle pid request
  loop() ->
      receive
          {Pid, Msg} when is_pid(Pid) ->
              spawn(fun() -> read({Pid, Msg}) end),
              loop();
          _ -> loop()
      end.
  
  
negative.code:     {ok, Client} = inet:peername(Sock),  % Client -> {Address, Port}
      {ok, Bin} = gen_tcp:recv(Sock, 0),
      T = binary_to_term(Bin),
      Pid = whereis(meeqo_nameserver),
      case T of
          {886} -> Pid ! {remove, Client};
          {GrpName} when is_atom(GrpName) -> Pid ! {resolve, GrpName, Sock};
          {GrpList} when is_list(GrpList) -> Pid ! {add, Client, GrpList};
          _ -> error
      end.
  
  