最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Differences between io() and io.connect() using socket.io - Stack Overflow

programmeradmin4浏览0评论

I would like to know what are the differences between

var socket = io();

and

var socket = io.connect();

using socket.io in my script (client side)

Thank you!

I would like to know what are the differences between

var socket = io();

and

var socket = io.connect();

using socket.io in my script (client side)

Thank you!

Share Improve this question asked Aug 5, 2017 at 11:48 AidoruAidoru 5651 gold badge5 silver badges16 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 17

There is no difference.

If you look at the source code for the SocketIO client, io is declared as follows:

module.exports = exports = lookup;

And io.connect() is declared in the same way:

exports.connect = lookup;

They both refer to the same (internal) function lookup.

I think that io.connect exists to make the client backward patible with older versions of SocketIO.

发布评论

评论列表(0)

  1. 暂无评论