Aidoru
Aidoru

Reputation: 565

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)

Thank you!

Upvotes: 14

Views: 6572

Answers (1)

robertklep
robertklep

Reputation: 203231

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.

Upvotes: 17

Related Questions