Looks up an existing `Manager` for multiplexing.
If the user summons:

`io('http://localhost/a');`
`io('http://localhost/b');`

We reuse the existing instance based on same scheme/port/host,
and we initialize sockets for each namespace.

@api public
340112
function lookup(uri, opts) {
    if (typeof uri === "object") {
      opts = uri;
      uri = undefined;
    }

    opts = opts || {};

    var parsed = url_1(uri);
    var source = parsed.source;
    var id = parsed.id;
    var path = parsed.path;
    var sameNamespace = cache[id] && path in cache[id].nsps;
    var newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;

    var io;

    if (newConnection) {
      debug("ignoring socket cache for %s", source);
      io = manager(source, opts);
    } else {
      if (!cache[id]) {
        debug("new io instance for %s", source);
        cache[id] = manager(source, opts);
      }
      io = cache[id];
    }
    if (parsed.query && !opts.query) {
      opts.query = parsed.query;
    }
    return io.socket(parsed.path, opts);
  }
594029
def init(port=8813, numRetries=10, host="localhost", label="default"):
    
    _connections[label] = connect(port, numRetries, host)
    switch(label)
    return getVersion()
801046
def get_a_manager(threadPool_settings=None):
    
    global __singleton_manager
    if __singleton_manager is None:
        def _thread_entry():
            if prctl:
                prctl.set_name('mirte manager')
            m.run()
            l.info('manager.run() returned')
        l = logging.getLogger('mirte.get_a_manager')
        l.info("Creating new instance")
        m = Manager(logging.getLogger('mirte'))
        if threadPool_settings:
            m.update_instance('threadPool', threadPool_settings)
        threading.Thread(target=_thread_entry).start()
        m.running_event.wait()
        __singleton_manager = m
    return __singleton_manager
252588
function init(entry, socket, req) {  // {{{2
/**
 * Class constructor
 *
 * @param entry {Object} Entry of xorg kind
 *
 * @method constructor
 */

  this.entry = entry;

  O.link.open(this, socket);
}
1177013
function NetworkInterface(name, address) {
  this._id = name || 'INADDR_ANY';
  this._multicastAddr = address;

  debug('Creating new NetworkInterface on `%s`', this._id);
  EventEmitter.call(this);

  // socket binding
  this._usingMe = 0;
  this._isBound = false;
  this._sockets = [];
  this._mutex = new Mutex();

  // incoming / outgoing records
  this.cache = new ExpiringRecordCollection([], `${this._id}'s cache`);
  this._history = new ExpiringRecordCollection([], `${this._id}'s history`);

  // outgoing packet buffers (debugging)
  this._buffers = [];
}
730670
function Client(host, port) {
    // Invokes with new if called without
    if (false === (this instanceof Client)) {
  	return new Client(host, port)
    }

    this.host = host;
    this.port = port;
}
458813
function (host) {
        /*
        * For Host match, we are considering the port with the host, hence we are using getRemote() instead of getHost()
        * We need to address three cases for the host urlStr
        * 1. * It matches all the host + protocol,  hence we are not having any parsing logic for it.
        * 2. *.foo.bar.com Here the prefix could be anything but it should end with foo.bar.com
        * 3. foo.bar.com This is the absolute matching needs to done.
        */
        var matchRegexObject = this._matchPatternObject;
        return (
            this.matchAnyHost(matchRegexObject) ||
            this.matchAbsoluteHostPattern(matchRegexObject, host) ||
            this.matchSuffixHostPattern(matchRegexObject, host)
        );
    }
83567
protected Map<String, AbstractServer> createServices(ServerSetup[] config, Managers mgr) {
        Map<String, AbstractServer> srvc = new HashMap<>();
        for (ServerSetup setup : config) {
            if (srvc.containsKey(setup.getProtocol())) {
                throw new IllegalArgumentException("Server '" + setup.getProtocol() + "' was found at least twice in the array");
            }
            final String protocol = setup.getProtocol();
            if (protocol.startsWith(ServerSetup.PROTOCOL_SMTP)) {
                srvc.put(protocol, new SmtpServer(setup, mgr));
            } else if (protocol.startsWith(ServerSetup.PROTOCOL_POP3)) {
                srvc.put(protocol, new Pop3Server(setup, mgr));
            } else if (protocol.startsWith(ServerSetup.PROTOCOL_IMAP)) {
                srvc.put(protocol, new ImapServer(setup, mgr));
            }
        }
        return srvc;
    }
1285382
private ServerSocket createServerSocket(int port) throws IOException {
    try {
      ServerSocket sock = new ServerSocket();
      // Prevent 2MSL delay problem on server restarts
      sock.setReuseAddress(true);
      // Bind to listening port
      if (port == 0) {
        sock.bind(null);
        serverPort = sock.getLocalPort();
      } else {
        sock.bind(new InetSocketAddress(port));
      }
      return sock;
    } catch (IOException ioe) {
      throw new IOException("Could not create ServerSocket on port " + port + "." +
                            ioe);
    }
  }
423290
function host(){
	var app = leachApp(connect())
	for(var x in host.prototype)app[x] = host.prototype[x]
	return app
}
386425
def lookup!(nameserver=nil)
      resolver = Resolv.resolver(nameserver)
      hosts = begin
                resolver.getnames(self.address.to_s)
              rescue
                []
              end

      hosts.map! do |name|
        HostName.first_or_create(
          :address => name,
          :ip_addresses => [self]
        )
      end

      return hosts
    end
1079330
def lookup_server(req)
      @virtual_hosts.find{|s|
        (s[:BindAddress].nil? || req.addr[3] == s[:BindAddress]) &&
        (s[:Port].nil?        || req.port == s[:Port])           &&
        ((s[:ServerName].nil?  || req.host == s[:ServerName]) ||
         (!s[:ServerAlias].nil? && s[:ServerAlias].find{|h| h === req.host}))
      }
    end
599258
@Override
	public NIOClientSocketHandler createClientHandler(NIOTcpMultiplexer multiplexer, SocketChannel socketChannel)
	{
		try
		{
		    String clientId = UUIDProvider.getInstance().getShortUUID();
			NIOTcpPacketTransport transport = new NIOTcpPacketTransport(clientId,multiplexer,socketChannel,settings);
			ClientProcessor clientProcessor = new ClientProcessor(clientId,this,localEngine,transport);
			registerClient(clientProcessor);
			clientProcessor.start();
			
			return transport;
		}
		catch (PacketTransportException e)
		{
			log.error("Cannot create client processor",e);
			return null;
		}
	}
1014152
function() {
    var self = this;
    // Unfortunately we can't use a connect middleware here since
    // sockjs installs itself prior to all existing listeners
    // (meaning prior to any connect middlewares) so we need to take
    // an approach similar to overshadowListeners in
    // https://github.com/sockjs/sockjs-node/blob/cf820c55af6a9953e16558555a31decea554f70e/src/utils.coffee
    _.each(['request', 'upgrade'], function(event) {
      var httpServer = WebApp.httpServer;
      var oldHttpServerListeners = httpServer.listeners(event).slice(0);
      httpServer.removeAllListeners(event);

      // request and upgrade have different arguments passed but
      // we only care about the first one which is always request
      var newListener = function(request /*, moreArguments */) {
        // Store arguments for use within the closure below
        var args = arguments;

        // Rewrite /websocket and /websocket/ urls to /sockjs/websocket while
        // preserving query string.
        var parsedUrl = url.parse(request.url);
        if (parsedUrl.pathname === pathPrefix + '/websocket' ||
            parsedUrl.pathname === pathPrefix + '/websocket/') {
          parsedUrl.pathname = self.prefix + '/websocket';
          request.url = url.format(parsedUrl);
        }
        _.each(oldHttpServerListeners, function(oldListener) {
          oldListener.apply(httpServer, args);
        });
      };
      httpServer.addListener(event, newListener);
    });
  }
622498
private static boolean registerURIPatternPath(String name, int port,
			RequestHandler handler,	RequestMapper mapper) {
		Matcher m = null;
		m = URI_PATTERN.matcher(name);
		
		if (m.matches()) {
			String host = m.group(2);
			String portString = m.group(3);
			
			if ((portString != null) && portString.startsWith(":")) {
				port = Integer.parseInt(portString.substring(1));
			}
			
			String path = m.group(4);
			
			mapper.addRequestHandler(port, null, path, handler);
			return true;
		}
		return false;
	}
1028858
def lookup!(nameserver=nil)
      resolver = Resolv.resolver(nameserver)
      ips = begin
              resolver.getaddresses(self.address)
            rescue
              []
            end

      ips.map! do |addr|
        IPAddress.first_or_create(
          :address => addr,
          :host_names => [self]
        )
      end

      return ips
    end
619389
private String getServerName (String osgiName) throws BadServerException {
		String result = osgiName;
		if (null == result) {
			if (registeredServers.isEmpty()) { // wait for the first one
				haveDefaultProviders = true; // only allow one server
				result = FIRST_SERVER;
			} else
			if (registeredServers.size() == 1) { // use the only one
				haveDefaultProviders = true; // only allow one server
				result = registeredServers.keySet().iterator().next();
			} else {
				throw new BadServerException();
			}
		}
		return result;
	}