博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
app.listen(3000)与app是不一样的
阅读量:6570 次
发布时间:2019-06-24

本文共 5704 字,大约阅读时间需要 19 分钟。

前者是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;

转载于:https://www.cnblogs.com/suoking/p/5335216.html

你可能感兴趣的文章
Kotlin系列之枚举类
查看>>
给你一个全自动的屏幕适配方案(基于SW方案)二 —— Calces.Screen插件拓展功能升级...
查看>>
MIT 6.824 学习笔记(一)--- RPC 详解
查看>>
【追光者系列】Hikari连接池大小多大合适?(第一弹)
查看>>
一次性搞懂JavaScript 执行机制
查看>>
程序员思维看爱情是什么?
查看>>
Awesome Go
查看>>
如何正确上传一张图片?
查看>>
Android基础 写给新手的Android环境配置
查看>>
界面无小事(六):来做个好看得侧拉菜单!
查看>>
Spring 数据处理框架的演变
查看>>
为什么要使用git pull --rebase?
查看>>
SpringBoot集成gRPC微服务工程搭建实践
查看>>
requestAnimationFrame用法
查看>>
iOS 蓝牙使用小结 bluetooth
查看>>
computed、watch和methods特性比较
查看>>
MySQL——优化ORDER BY语句
查看>>
iOS:重识Transform和frame
查看>>
spring boot / cloud (二十) 相同服务,发布不同版本,支撑并行的业务需求
查看>>
docker任务调度工具: ofelia
查看>>