zoukankan      html  css  js  c++  java
  • app.listen(3000)与app是不一样的

    前者是server代码如下

    Server {
      domain: null,
      _events:
       { request:
          { [Function]
            domain: undefined,
            _events: [Object],
            _maxListeners: undefined,
            setMaxListeners: [Function: setMaxListeners],
            getMaxListeners: [Function: getMaxListeners],
            emit: [Function: emit],
            addListener: [Function: addListener],
            on: [Function: addListener],
            once: [Function: once],
            removeListener: [Function: removeListener],
            removeAllListeners: [Function: removeAllListeners],
            listeners: [Function: listeners],
            listenerCount: [Function: listenerCount],
            init: [Function: init],
            defaultConfiguration: [Function: defaultConfiguration],
            lazyrouter: [Function: lazyrouter],
            handle: [Function: handle],
            use: [Function: use],
            route: [Function: route],
            engine: [Function: engine],
            param: [Function: param],
            set: [Function: set],
            path: [Function: path],
            enabled: [Function: enabled],
            disabled: [Function: disabled],
            enable: [Function: enable],
            disable: [Function: disable],
            checkout: [Function],
            connect: [Function],
            copy: [Function],
            delete: [Function],
            get: [Function],
            head: [Function],
            lock: [Function],
            'm-search': [Function],
            merge: [Function],
            mkactivity: [Function],
            mkcalendar: [Function],
            mkcol: [Function],
            move: [Function],
            notify: [Function],
            options: [Function],
            patch: [Function],
            post: [Function],
            propfind: [Function],
            proppatch: [Function],
            purge: [Function],
            put: [Function],
            report: [Function],
            search: [Function],
            subscribe: [Function],
            trace: [Function],
            unlock: [Function],
            unsubscribe: [Function],
            all: [Function: all],
            del: [Function],
            render: [Function: render],
            listen: [Function: listen],
            request: [Object],
            response: [Object],
            cache: {},
            engines: {},
            settings: [Object],
            _eventsCount: 1,
            locals: [Object],
            mountpath: '/',
            _router: [Object] },
         connection: [Function: connectionListener],
         clientError: [Function] },
      _eventsCount: 3,
      _maxListeners: undefined,
      _connections: 0,
      _handle:
       TCP {
         _externalStream: {},
         fd: 11,
         reading: false,
         owner: [Circular],
         onread: null,
         onconnection: [Function: onconnection],
         writeQueueSize: 0 },
      _usingSlaves: false,
      _slaves: [],
      _unref: false,
      allowHalfOpen: true,
      pauseOnConnect: false,
      httpAllowHalfOpen: false,
      timeout: 120000,
      _pendingResponseData: 0,
      _connectionKey: '6::::3000' }

    后者还没有实例化算是一个类:代码如下:

    { [Function]
      domain: undefined,
      _events: { mount: [Function: onmount] },
      _maxListeners: undefined,
      setMaxListeners: [Function: setMaxListeners],
      getMaxListeners: [Function: getMaxListeners],
      emit: [Function: emit],
      addListener: [Function: addListener],
      on: [Function: addListener],
      once: [Function: once],
      removeListener: [Function: removeListener],
      removeAllListeners: [Function: removeAllListeners],
      listeners: [Function: listeners],
      listenerCount: [Function: listenerCount],
      init: [Function: init],
      defaultConfiguration: [Function: defaultConfiguration],
      lazyrouter: [Function: lazyrouter],
      handle: [Function: handle],
      use: [Function: use],
      route: [Function: route],
      engine: [Function: engine],
      param: [Function: param],
      set: [Function: set],
      path: [Function: path],
      enabled: [Function: enabled],
      disabled: [Function: disabled],
      enable: [Function: enable],
      disable: [Function: disable],
      checkout: [Function],
      connect: [Function],
      copy: [Function],
      delete: [Function],
      get: [Function],
      head: [Function],
      lock: [Function],
      'm-search': [Function],
      merge: [Function],
      mkactivity: [Function],
      mkcalendar: [Function],
      mkcol: [Function],
      move: [Function],
      notify: [Function],
      options: [Function],
      patch: [Function],
      post: [Function],
      propfind: [Function],
      proppatch: [Function],
      purge: [Function],
      put: [Function],
      report: [Function],
      search: [Function],
      subscribe: [Function],
      trace: [Function],
      unlock: [Function],
      unsubscribe: [Function],
      all: [Function: all],
      del: [Function],
      render: [Function: render],
      listen: [Function: listen],
      request: IncomingMessage { app: [Circular] },
      response: ServerResponse { app: [Circular] },
      cache: {},
      engines: {},
      settings:
       { 'x-powered-by': true,
         etag: 'weak',
         'etag fn': [Function: wetag],
         env: 'development',
         'query parser': 'extended',
         'query parser fn': [Function: parseExtendedQueryString],
         'subdomain offset': 2,
         'trust proxy': false,
         'trust proxy fn': [Function: trustNone],
         view: [Function: View],
         views: '/Users/Amanda/Downloads/aa/blog/views',
         'jsonp callback name': 'callback' },
      _eventsCount: 1,
      locals:
       { settings:
          { 'x-powered-by': true,
            etag: 'weak',
            'etag fn': [Function: wetag],
            env: 'development',
            'query parser': 'extended',
            'query parser fn': [Function: parseExtendedQueryString],
            'subdomain offset': 2,
            'trust proxy': false,
            'trust proxy fn': [Function: trustNone],
            view: [Function: View],
            views: '/Users/Amanda/Downloads/aa/blog/views',
            'jsonp callback name': 'callback' } },
      mountpath: '/',
      _router:
       { [Function: router]
         params: {},
         _params: [],
         caseSensitive: false,
         mergeParams: undefined,
         strict: false,
         stack: [ [Object], [Object], [Object] ] } }

    另外app.createServer()此方法已经被废除;属于旧代码;websocket要监听服务器,监听实例化得app,即第一种server;

    坚持下去就能成功
  • 相关阅读:
    剔除list中相同的结构体数据
    API Gateway微服务
    Webpack vs Gulp
    客服系统
    利用 istio 来对运行在 Kubernetes 上的微服务进行管理
    微服务环境搭建
    简易的开发框架(微服务) Asp.Net Core 2.0
    Istio官方文档中文版
    Hangfire Net Core2
    IIS7性能优化
  • 原文地址:https://www.cnblogs.com/suoking/p/5335216.html
Copyright © 2011-2022 走看看