<commit_before># SailsSocket

In most cases, you only need to connect a single socket from your client-side application.  By default in Sails applications, the `sails.io.js` client library automatically connects a socket (`io.socket`).  This is the recommended choice for 99% of apps.

However, for certain advanced use cases, it can be helpful to connect additional sockets from the same instance of the socket client (e.g. browser tab).  For this reason, Sails exposes the `SailsSocket` class.


### Overview

The `sails.io.js` library works by wrapping low-level [Socket.io](http://socket.io) clients in instances of the `SailsSocket` class.  This class provides higher-level methods like [`.get()`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-socket-get) and [`.post()`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-socket-post) to your sockets, allowing you to communicate with your Sails app in a familiar way.


### Creating a SailsSocket instance

Any web page which loads the `sails.io.js` will create a new SailsSocket instance on page load unless [`io.sails.autoconnect`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-sails#?autoconnect) is set to `false`.  This instance is then available as the global variable [`io.socket`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-socket).

Additional SailsSocket instances can be created via calls to [`io.sails.connect`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-sails#?the-connect-method).

```
var newSailsSocket = io.sails.connect();
```


<docmeta name="displayName" value="SailsSocket"><commit_msg>Update SailsSocket.md<commit_after># SailsSocket

In most cases, you only need to connect a single socket from your client-side application.  By default in Sails applications, the `sails.io.js` client library automatically connects a socket (`io.socket`).  This is the recommended choice for 99% of apps.

However, for certain advanced use cases, it can be helpful to connect additional sockets from the same instance of the socket client (e.g. browser tab).  For this reason, Sails exposes the `SailsSocket` class.


### Overview

The `sails.io.js` library works by wrapping low-level [Socket.io](http://socket.io) clients in instances of the `SailsSocket` class.  This class provides higher-level methods like [`.get()`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-socket-get) and [`.post()`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-socket-post) to your sockets, allowing you to communicate with your Sails app in a familiar way.


### Creating a SailsSocket instance

Any web page which loads the `sails.io.js` will create a new SailsSocket instance on page load unless [`io.sails.autoconnect`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-sails#?autoconnect) is set to `false`.  This instance is then available as the global variable [`io.socket`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-socket).

Additional SailsSocket instances can be created via calls to [`io.sails.connect`](http://sailsjs.org/documentation/reference/web-sockets/socket-client/io-sails#?the-connect-method):

```
var newSailsSocket = io.sails.connect();
```


<docmeta name="displayName" value="SailsSocket">
{'fraction_non_alphanumeric': 0.11506768687463213, 'fraction_numerical': 0.0011771630370806356, 'mean_word_length': 5.048042704626335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1085521', 'n_tokens_mistral': 1009, 'n_tokens_neox': 962, 'n_words': 330}