Differences between io() and io.connect() using socket.io

时间:2017-08-05 11:48:59

标签: javascript node.js socket.io socket.io-1.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!

1 个答案:

答案 0 :(得分:6)

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 compatible with older versions of SocketIO.