[英]Differences between io() and io.connect() using socket.io
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) 在我的脚本中使用socket.io(客户端)
Thank you! 谢谢!
There is no difference. 没有区别。
If you look at the source code for the SocketIO client, io
is declared as follows : 如果查看SocketIO客户端的源代码,
io
声明如下 :
module.exports = exports = lookup;
And io.connect()
is declared in the same way : io.connect()
以相同的方式声明:
exports.connect = lookup;
They both refer to the same (internal) function lookup
. 它们都引用相同的(内部)函数
lookup
。
I think that io.connect
exists to make the client backward compatible with older versions of SocketIO. 我认为
io.connect
存在使客户端向后兼容旧版本的SocketIO。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.