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!
答案 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.