<commit_before>
# Super Sockets

  Super Sockets is a message-oriented socket library for node.js heavily inspired by zeromq.

## Installation

    $ npm install super-sockets

## Features

  - message oriented
  - automated reconnection
  - light-weight wire protocol
  - light-weight implementation (~300 SLOC)
  - supports arbitrary binary message (msgpack, json, BLOBS, etc)
  - supports JSON messages
  - push / pull pattern
  - pub / sub pattern
  - event emitter pattern

## Push / Pull

`PushSocket`s distribute messages round-robin:

```js
var ss = require('super-sockets')
  , sock = ss.socket('push');

sock.bind(3000);
console.log('push server started');

setInterval(function(){
  process.stdout.write('.');
  sock.send('hello');
}, 150);
```

Receiver of `PushSocket` messages:

```js
var ss = require('super-sockets')
  , sock = ss.socket('pull');

sock.connect(3000);

sock.on('message', function(msg){
  console.log(msg.toString());
});
```

## Pub / Sub

`PubSocket`s send messages to all subscribers without queueing:

```js
var ss = require('super-sockets')
  , sock = ss.socket('pub');

sock.bind(3000);
console.log('pub server started');

setInterval(function(){
  console.log('sending');
  sock.send('hello');
}, 500);
```

`SubSocket` provides selective reception of messages from a `PubSocket`:

```js
var ss = require('super-sockets')
  , sock = ss.socket('sub');

sock.connect(3000);

sock.on('message', function(msg){
  console.log(msg.toString());
});
```

## EmitterSocket

`EmitterSocket`'s send and receive messages behaving like regular node `EventEmitter`s.
This is achieved by using pub / sub sockets behind the scenes. Currently we simply choose
define the `EmitterSocket` as a `PubSocket` if you `.bind()`, and `SubSocket` if you `.connect()`,
providing the natural API you're used to:

server.js:

```js
var ss = require('super-sockets')
  , sock = ss.socket('emitter');

sock.bind(3000);
console.log('pub server started');

setInterval(function(){
  sock.emit('login', { name: 'tobi' });
}, 500);
```

client.js:

```js
var ss = require('super-sockets')
  , sock = ss.socket('emitter');

sock.connect(3000);
console.log('sub client connected');

sock.on('login', function(user){
  console.log('%s signed in', user.name);
});
```

## Protocol

  The wire protocol is simple and very much zeromq-like, where `<length>` is
  a 24 bit unsigned integer, representing a maximum length of 2^24, roughly ~16mb,
  so you should be good :p

```
 octet:     0      1      2      3      <length>
        +------+------+------+------+------------------...
        | meta | <length>           | data ...
        +------+------+------+------+------------------...
```

## What's it good for?

  Super sockets are not meant to combat zeromq by any means,
  but provide a nice solution when you don't need the insane
  nanosecond latency or language interoperability that zeromq provides
  as super sockets do not rely on any third-party compiled libraries.

## Running tests

```
$ npm install
$ make test
```

## Todo

  - more tests
  - code cov
  - acks
  - clean up queue / sock<commit_msg>add more docs<commit_after>
# Super Sockets

  Super Sockets is a message-oriented socket library for node.js heavily inspired by zeromq.

## Installation

    $ npm install super-sockets

## Features

  - message oriented
  - automated reconnection
  - light-weight wire protocol
  - light-weight implementation (~300 SLOC)
  - supports arbitrary binary message (msgpack, json, BLOBS, etc)
  - supports JSON messages
  - push / pull pattern
  - pub / sub pattern
  - event emitter pattern

## Push / Pull

`PushSocket`s distribute messages round-robin:

```js
var ss = require('super-sockets')
  , sock = ss.socket('push');

sock.bind(3000);
console.log('push server started');

setInterval(function(){
  process.stdout.write('.');
  sock.send('hello');
}, 150);
```

Receiver of `PushSocket` messages:

```js
var ss = require('super-sockets')
  , sock = ss.socket('pull');

sock.connect(3000);

sock.on('message', function(msg){
  console.log(msg.toString());
});
```

## Pub / Sub

`PubSocket`s send messages to all subscribers without queueing:

```js
var ss = require('super-sockets')
  , sock = ss.socket('pub');

sock.bind(3000);
console.log('pub server started');

setInterval(function(){
  console.log('sending');
  sock.send('hello');
}, 500);
```

`SubSocket` provides selective reception of messages from a `PubSocket`:

```js
var ss = require('super-sockets')
  , sock = ss.socket('sub');

sock.connect(3000);

sock.on('message', function(msg){
  console.log(msg.toString());
});
```

## EmitterSocket

`EmitterSocket`'s send and receive messages behaving like regular node `EventEmitter`s.
This is achieved by using pub / sub sockets behind the scenes. Currently we simply choose
define the `EmitterSocket` as a `PubSocket` if you `.bind()`, and `SubSocket` if you `.connect()`,
providing the natural API you're used to:

server.js:

```js
var ss = require('super-sockets')
  , sock = ss.socket('emitter');

sock.bind(3000);
console.log('pub server started');

setInterval(function(){
  sock.emit('login', { name: 'tobi' });
}, 500);
```

client.js:

```js
var ss = require('super-sockets')
  , sock = ss.socket('emitter');

sock.connect(3000);
console.log('sub client connected');

sock.on('login', function(user){
  console.log('%s signed in', user.name);
});
```

## Protocol

  The wire protocol is simple and very much zeromq-like, where `<length>` is
  a 24 bit unsigned integer, representing a maximum length of 2^24, roughly ~16mb,
  so you should be good :p

```
 octet:     0      1      2      3      <length>
        +------+------+------+------+------------------...
        | meta | <length>           | data ...
        +------+------+------+------+------------------...
```

## What's it good for?

  Super sockets are not meant to combat zeromq nor provide feature parity,
  but provide a nice solution when you don't need the insane
  nanosecond latency or language interoperability that zeromq provides
  as super sockets do not rely on any third-party compiled libraries.

## Running tests

```
$ npm install
$ make test
```

## Todo

  - more tests
  - code cov
  - acks
  - clean up queue / sock
{'fraction_non_alphanumeric': 0.1699743918053777, 'fraction_numerical': 0.015044814340588988, 'mean_word_length': 3.297799174690509, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '437932', 'n_tokens_mistral': 2056, 'n_tokens_neox': 1905, 'n_words': 624}