public static ProtocolEndpoint createEndpoint(int type, InetSocketAddress target) {
   switch (type) {
     case ProtocolEndpoint.PROTOCOL_TCP:
       {
         return (tcp_handler.create(target));
       }
     case ProtocolEndpoint.PROTOCOL_UDP:
       {
         return (udp_handler.create(target));
       }
     default:
       {
         ProtocolEndpointHandler handler = other_handlers.get(type);
         if (handler != null) {
           return (handler.create(target));
         }
         return (null);
       }
   }
 }
  public static void registerHandler(ProtocolEndpointHandler handler) {
    int type = handler.getType();

    if (type == ProtocolEndpoint.PROTOCOL_TCP) {

      tcp_handler = handler;

    } else if (type == ProtocolEndpoint.PROTOCOL_UDP) {

      udp_handler = handler;

    } else {

      other_handlers.put(type, handler);
    }
  }