docs: function createServer(listen, opt) {
  
    if (!listen) {
      throw new TypeError('listen required');
    }
    var options = opt || Object.create(null);
    var my = {
      keepalive: Number(options.keepalive) || 2000,
      callback: typeof options.callback === 'function' ? options.callback : false,
      http: false,
      https: false
    };
    if (typeof options.http === 'object') {
      my.http = {
        port: Number(options.http.port) || 3000,
        host: String(options.http.host || '127.0.0.1')
      };
    }
    if (typeof options.https === 'object') {
      my.https = options.https;
      my.https.port = Number(options.https.port) || 3000;
      my.https.host = String(options.https.host || '127.0.0.1');
    }
  
    var hosts = Object.create(null);
    var server = net.createServer(function(sock) {
  
      sock.setKeepAlive(true, my.keepalive); // https://en.wikipedia.org/wiki/Keepalive
      sock.on('data', function(buff) {
  
        if (sock._id) {
          hosts[sock._id] = {
            state: sock.readyState,
            beat: Date.now()
          };
        } else if (buff.length > 1) { // set client id
          var _id = String(buff);
          hosts[_id] = {
            state: sock.readyState,
            beat: Date.now()
          };
          sock._id = _id;
        }
        return;
  
      }).on('close', function(had_error) {
  
        if (sock._id) {
          hosts[sock._id] = {
            state: sock.readyState,
            beat: Date.now()
          };
        }
        // error hook [with client id]
        return my.callback !== false ? my.callback(had_error, sock._id) : null;
      });
    });
  
    if (options.host && typeof listen === 'number') { // tpc only
      server.listen(listen, options.host);
    } else {
      server.listen(listen);
    }
  
    if (my.http || my.https) {
      var web = function(req, res) {
  
        var out = '';
        res.setHeader('Content-Type', 'application/json; charset=utf-8');
        var url = decodeURI(req.url);
        url = url.substr(1, url.length);
        if (url === '') {
          out = JSON.stringify(hosts);
        } else if (hosts[url] !== undefined) {
          out = JSON.stringify(hosts[url]);
        } else {
          res.statusCode = 404;
        }
        return res.end(out);
      };
      if (my.http) {
        require('http').createServer(web).listen(my.http.port, my.http.host);
      }
      if (my.https) {
        require('https').createServer(my.https, web).listen(my.https.port,
          my.https.host);
      }
    }
  
    server._hosts = hosts; // hosts reference
    return server;
  }