From c0181c45a034d79794118ce0a0063df706451314 Mon Sep 17 00:00:00 2001 From: Brandon Nozaki Miller Date: Wed, 23 Mar 2016 00:43:18 -0700 Subject: [PATCH] Create gh-pages branch via GitHub --- index.html | 306 ++++++++++++++++++++++++++++++++++++++++------------ params.json | 8 +- 2 files changed, 244 insertions(+), 70 deletions(-) diff --git a/index.html b/index.html index 69a1d75..e219eb6 100644 --- a/index.html +++ b/index.html @@ -32,14 +32,20 @@

-node-ipc

+node-ipc -

a nodejs module for local and remote Inter Process Communication with full support for Linux, Mac and Windows.
-A great solution for Neural Networking in Node.JS

+

a nodejs module for local and remote Inter Process Communication with full support for Linux, Mac and Windows. It also supports all forms of socket communication from low level unix and windows sockets to UDP and secure TLS and TCP sockets.

+ +

A great solution for complex multiprocess Neural Networking in Node.JS

npm install node-ipc

+

+NPM Stats

+

npm info : See npm trends and stats for node-ipc
+NPM +Package Quality
node-ipc npm version supported node version for node-ipc total npm downloads for node-ipc monthly npm downloads for node-ipc npm licence for node-ipc

RIAEvangelist

@@ -47,6 +53,9 @@ A great solution for Neural Networking in Node.JS

GitHub info :
node-ipc GitHub Release GitHub license node-ipc license open issues for node-ipc on GitHub

+

Codacy info :
+Codacy Badge Codacy Badge

+

Package details websites :

    @@ -58,13 +67,21 @@ A great solution for Neural Networking in Node.JS

    This work is licenced via the DBAD Public Licence.

    +

    +Testing

    + +

    npm test will run the jasmine tests with istanbul for node-ipc and generate a coverage report in the spec folder.

    + +

    You may want to install jasmine and istanbul globally with sudo npm install -g jasmine istanbul

    +

    -Contents

    +Contents
    1. Types of IPC Sockets and Supporting OS
    2. +
    3. IPC Config
    4. IPC Methods @@ -78,6 +95,8 @@ A great solution for Neural Networking in Node.JS

  • IPC Stores and Default Variables
  • +
  • IPC Events
  • +
  • Multiple IPC instances
  • Basic Examples @@ -85,17 +104,17 @@ A great solution for Neural Networking in Node.JS

  • Server for Unix||Windows Sockets & TCP Sockets
  • Client for Unix||Windows Sockets & TCP Sockets
  • Server & Client for UDP Sockets
  • -
  • Raw Buffers or Binary Sockets
  • +
  • Raw Buffers, Real Time and / or Binary Sockets
  • Working with TLS/SSL Socket Servers & Clients
  • -
  • Advanced Examples
  • +
  • Node Code Examples

  • -Types of IPC Sockets

    +Types of IPC Sockets @@ -158,6 +177,9 @@ A great solution for Neural Networking in Node.JS


    +

    +IPC Config

    +

    ipc.config

    Set these variables in the ipc.config scope to overwrite or set default values.

    @@ -171,7 +193,10 @@ A great solution for Neural Networking in Node.JS

    networkPort :8000, encoding :'utf8', rawBuffer :false, + sync :false, silent :false, + logInColor :true, + logDepth :5, maxConnections :100, retry :500, maxRetries :false, @@ -216,10 +241,22 @@ A great solution for Neural Networking in Node.JS

    + + + + + + + + + + + + @@ -241,55 +278,34 @@ A great solution for Neural Networking in Node.JS


    -IPC Methods

    +IPC Methods

    These methods are available in the IPC Scope.


    -log
    +log

    ipc.log(a,b,c,d,e...);

    -

    ipc.log will accept any number of arguments and if ipc.config.silent is not set, it will concat them all with a sincle space ' ' between them and then log them to the console. This is fast because it prevents any concatenation from happening if the ipc is set to silent. That way if you leave your logging in place it should not effect performance.

    +

    ipc.log will accept any number of arguments and if ipc.config.silent is not set, it will concat them all with a single space ' ' between them and then log them to the console. This is fast because it prevents any concatenation from happening if the ipc.config.silent is set true. That way if you leave your logging in place it should have almost no effect on performance.

    -

    The log also supports colors implementation. All of the available styles are supported and the theme styles are as follows :

    +

    The log also uses util.inspect You can control if it should log in color as well as the log depth via ipc.config

    -    {
    -        good    : 'green',
    -        notice  : 'yellow',
    -        warn    : 'red',
    -        error   : 'redBG',
    -        debug   : 'magenta',
    -        variable: 'cyan',
    -        data    : 'blue'
    -    }    
    -
    - -

    You can override any of these settings by requireing colors and setting the theme as follows :

    - -
    -    var colors=require('colors');
    -
    -    colors.setTheme(
    -        {
    -            good    : 'zebra',
    -            notice  : 'redBG',
    -            ...
    -        }    
    -    );
    +    ipc.config.logInColor=true; //default
    +    ipc.config.logDepth=5; //default    
     

    -connectTo
    +connectTo

    ipc.connectTo(id,path,callback);

    -

    Used for connecting as a client to local Unix Sockets and Windows Sockets. This is the fastst way for processes on the same machine to communicate because it bypasses the network card which TCP and UDP must both use.

    +

    Used for connecting as a client to local Unix Sockets and Windows Sockets. This is the fastest way for processes on the same machine to communicate because it bypasses the network card which TCP and UDP must both use.

    if true, data will be sent and received as a raw node Buffer NOT an Object as JSON. This is great for Binary or hex IPC, and communicating with other processes in languages like C and C++
    syncsynchronous requests. Clients will not send new requests until the server answers.
    silent turn on/off logging default is false which means logging is on
    logInColorturn on/off util.inspect colors for ipc.log
    logDepthset the depth for util.inspect during ipc.log
    maxConnections this is the max number of connections allowed to a socket. It is currently only being set on Unix Sockets. Other Socket types are using the system defaults.
    @@ -358,7 +374,7 @@ A great solution for Neural Networking in Node.JS

    'world', 'myapp.world', function(){ - ... + ... } ); @@ -366,7 +382,7 @@ A great solution for Neural Networking in Node.JS


    -connectToNet
    +connectToNet

    ipc.connectToNet(id,host,port,callback)

    @@ -419,7 +435,7 @@ So while the default is : (id,host,port,callback), the following examples will s ipc.connectToNet( 'world', function(){ - ... + ... } ); @@ -441,7 +457,7 @@ So while the default is : (id,host,port,callback), the following examples will s 'world', 3435, function(){ - ... + ... } ); @@ -449,7 +465,7 @@ So while the default is : (id,host,port,callback), the following examples will s
    -disconnect
    +disconnect

    ipc.disconnect(id)

    @@ -481,7 +497,7 @@ So while the default is : (id,host,port,callback), the following examples will s
    -serve
    +serve

    ipc.serve(path,callback);

    @@ -521,7 +537,7 @@ So while the default is : (id,host,port,callback), the following examples will s
         ipc.serve(
    -        function(){...}
    +        function(){...}
         );
     
    @@ -538,14 +554,14 @@ So while the default is : (id,host,port,callback), the following examples will s
         ipc.serve(
             '/tmp/myapp.myservice',
    -        function(){...}
    +        function(){...}
         );
     

    -serveNet
    +serveNet

    serveNet(host,port,UDPType,callback)

    @@ -568,12 +584,13 @@ So while the default is : (id,host,port,callback), the following examples will s - + - + @@ -601,7 +618,7 @@ So while the default is : (id,host,port,callback), the following examples will s
         ipc.serveNet(
    -        function(){...}
    +        function(){...}
         );
     
    @@ -610,7 +627,7 @@ So while the default is : (id,host,port,callback), the following examples will s
         ipc.serveNet(
             'udp4',
    -        function(){...}
    +        function(){...}
         );
     
    @@ -628,7 +645,7 @@ So while the default is : (id,host,port,callback), the following examples will s ipc.serveNet( 'MyMostAwesomeApp.com', 3435, - function(){...} + function(){...} ); @@ -639,14 +656,14 @@ So while the default is : (id,host,port,callback), the following examples will s 'MyMostAwesomeApp.com', 3435, 'udp4', - function(){...} + function(){...} );

    -IPC Stores and Default Variables

    +IPC Stores and Default Variables
    port optionalThe port on wunich the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specifiedThe port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified
    UDPType optionalIf set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set.If set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set. When using udp6 make sure to specify a valid IPv6 host, like ::1 +
    callback
    @@ -671,12 +688,119 @@ So while the default is : (id,host,port,callback), the following examples will s

    -Basic Examples

    +IPC Server Methods + +
    + + + + + + + + + + + + + + + + +
    methoddefinition
    startstart serving need top call serve or serveNet first to set up the server
    stopclose the server and stop serving
    + +
    + +

    +IPC Events

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    event nameparamsdefinition
    errorerr objtriggered when an error has occured
    connecttriggered when socket connected
    disconnecttriggered when socket disconnected
    destroytriggered when socket has been totally destroyed, no further auto retries will happen and all references are gone.
    databuffertriggered when ipc.config.rawBuffer is true and a message is received.
    your event typeyour event datatriggered when a JSON message is received. The event name will be the type string from your message and the param will be the data object from your message eg : { type:'myEvent',data:{a:1}} +
    + +

    +Multiple IPC Instances

    + +

    Sometimes you might need explicit and independent instances of node-ipc. Just for such scenarios we have exposed the core IPC class on the IPC singleton.

    + +
    +    const RawIPC=require('node-ipc').IPC;
    +    const ipc=new RawIPC;
    +    const someOtherExplicitIPC=new RawIPC;
    +
    +
    +    //OR
    +
    +    const ipc=require('node-ipc');
    +    const someOtherExplicitIPC=new ipc.IPC;
    +
    +
    +    //setting explicit configs
    +
    +    //keep one silent and the other verbose
    +    ipc.config.silent=true;
    +    someOtherExplicitIPC.config.silent=true;
    +
    +    //make one a raw binary and the other json based ipc
    +    ipc.config.rawBuffer=false;
    +
    +    someOtherExplicitIPC.config.rawBuffer=true;
    +    someOtherExplicitIPC.config.encoding='hex';
    +
    + +
    + +

    +Basic Examples

    You can find Advanced Examples in the examples folder. In the examples you will find more complex demos including multi client examples.

    -Server for Unix Sockets, Windows Sockets & TCP Sockets

    +Server for Unix Sockets, Windows Sockets & TCP Sockets

    The server is the process keeping a socket for IPC open. Multiple sockets can connect to this server and talk to it. It can also broadcast to all clients or emit to a specific client. This is the most basic example which will work for local Unix and Windows Sockets as well as local or remote network TCP Sockets.

    @@ -694,7 +818,8 @@ So while the default is : (id,host,port,callback), the following examples will s ipc.log('got a message : '.debug, data); ipc.server.emit( socket, - 'message', + 'message', //this can be anything you want so long as + //your client knows. data+' world!' ); } @@ -706,7 +831,7 @@ So while the default is : (id,host,port,callback), the following examples will s

-Client for Unix Sockets & TCP Sockets

+Client for Unix Sockets & TCP Sockets

The client connects to the servers socket for Inter Process Communication. The socket will receive events emitted to it specifically as well as events which are broadcast out on the socket by the server. This is the most basic example which will work for both local Unix Sockets and local or remote network TCP Sockets.

@@ -724,7 +849,7 @@ So while the default is : (id,host,port,callback), the following examples will s function(){ ipc.log('## connected to world ##'.rainbow, ipc.config.delay); ipc.of.world.emit( - 'message', + 'message', //any event or message type your server listens for 'hello' ) } @@ -736,7 +861,7 @@ So while the default is : (id,host,port,callback), the following examples will s } ); ipc.of.world.on( - 'message', + 'message', //any event or message type your server listens for function(data){ ipc.log('got a message from world : '.debug, data); } @@ -746,7 +871,7 @@ So while the default is : (id,host,port,callback), the following examples will s

-Server & Client for UDP Sockets

+Server & Client for UDP Sockets

UDP Sockets are different than Unix, Windows & TCP Sockets because they must be bound to a unique port on their machine to receive messages. For example, A TCP, Unix, or Windows Socket client could just connect to a separate TCP, Unix, or Windows Socket sever. That client could then exchange, both send and receive, data on the servers port or location. UDP Sockets can not do this. They must bind to a port to receive or send data.

@@ -755,7 +880,7 @@ So while the default is : (id,host,port,callback), the following examples will s

This is the most basic example which will work for both local and remote UDP Sockets.

-UDP Server 1 - "World"
+UDP Server 1 - "World"
     var ipc=require('../../../node-ipc');
@@ -786,13 +911,11 @@ So while the default is : (id,host,port,callback), the following examples will s
         }
     );
 
-    ipc.server.define.listen.message='This event type listens for message strings as value of data key.';
-
     ipc.server.start();
 
-UDP Server 2 - "Hello"
+UDP Server 2 - "Hello"

note we set the port here to 8001 because the world server is already using the default ipc.config.networkPort of 8000. So we can not bind to 8000 while world is using it.

@@ -825,15 +948,13 @@ So while the default is : (id,host,port,callback), the following examples will s } ); - ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; - ipc.server.start();

-Raw Buffer or Binary Sockets

+Raw Buffer or Binary Sockets -

Binary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is slightly different.

+

Binary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is slightly different. These may come in handy if working with embedded systems or C / C++ processes. You can even make sure to match C or C++ string typing.

When setting up a rawBuffer socket you must specify it as such :

@@ -865,6 +986,9 @@ So while the default is : (id,host,port,callback), the following examples will s

emit byte array buffer :

+    //hex encoding may work best for this.
+    ipc.config.encoding='hex';
+
     //server
     ipc.server.emit(
         socket,
@@ -877,9 +1001,11 @@ So while the default is : (id,host,port,callback), the following examples will s
     );
 
-

emit hex array buffer :

+

emit binary or hex array buffer, this is best for real time data transfer, especially whan connecting to C or C++ processes, or embedded systems :

+    ipc.config.encoding='hex';
+
     //server
     ipc.server.emit(
         socket,
@@ -892,8 +1018,50 @@ So while the default is : (id,host,port,callback), the following examples will s
     );
 
+

Writing explicit buffers, int types, doubles, floats etc. as well as big endian and little endian data to raw buffer nostly valuable when connecting to C or C++ processes, or embedded systems (see more detailed info on buffers as well as UInt, Int, double etc. here)[https://nodejs.org/api/buffer.html]:

+ +
+    ipc.config.encoding='hex';
+
+    //make a 6 byte buffer for example
+    const myBuffer=new Buffer(6).fill(0);
+
+    //fill the first 2 bytes with a 16 bit (2 byte) short unsigned int
+
+    //write a UInt16 (2 byte or short) as Big Endian
+    myBuffer.writeUInt16BE(
+        2, //value to write
+        0 //offset in bytes
+    );
+    //OR
+    myBuffer.writeUInt16LE(0x2,0);
+    //OR
+    myBuffer.writeUInt16LE(0x02,0);
+
+    //fill the remaining 4 bytes with a 32 bit (4 byte) long unsigned int
+
+    //write a UInt32 (4 byte or long) as Big Endian
+    myBuffer.writeUInt32BE(
+        16772812, //value to write
+        2 //offset in bytes
+    );
+    //OR
+    myBuffer.writeUInt32BE(0xffeecc,0)
+
+    //server
+    ipc.server.emit(
+        socket,
+        myBuffer
+    );
+
+    //client
+    ipc.server.emit(
+        myBuffer
+    );
+
+

-Licensed under DBAD license

+Licensed under DBAD license

See the DBAD license in your language or our licence.md file.

diff --git a/params.json b/params.json index ef84557..110ef76 100644 --- a/params.json +++ b/params.json @@ -1 +1,7 @@ -{"name":"Node-ipc","tagline":"Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS","body":"node-ipc\r\n================\r\n*a nodejs module for local and remote Inter Process Communication* with full support for Linux, Mac and Windows. \r\nA great solution for **Neural Networking** in Node.JS\r\n\r\n**npm install node-ipc**\r\n\r\n\r\nnpm info : [See npm trends and stats for node-ipc](http://npm-stat.com/charts.html?package=node-ipc&author=&from=&to=) \r\n![node-ipc npm version](https://img.shields.io/npm/v/node-ipc.svg) ![supported node version for node-ipc](https://img.shields.io/node/v/node-ipc.svg) ![total npm downloads for node-ipc](https://img.shields.io/npm/dt/node-ipc.svg) ![monthly npm downloads for node-ipc](https://img.shields.io/npm/dm/node-ipc.svg) ![npm licence for node-ipc](https://img.shields.io/npm/l/node-ipc.svg)\r\n\r\n[![RIAEvangelist](https://avatars3.githubusercontent.com/u/369041?v=3&s=100)](https://github.com/RIAEvangelist)\r\n\r\nGitHub info : \r\n![node-ipc GitHub Release](https://img.shields.io/github/release/RIAEvangelist/node-ipc.svg) ![GitHub license node-ipc license](https://img.shields.io/github/license/RIAEvangelist/node-ipc.svg) ![open issues for node-ipc on GitHub](https://img.shields.io/github/issues/RIAEvangelist/node-ipc.svg)\r\n\r\nPackage details websites :\r\n* [GitHub.io site](http://riaevangelist.github.io/node-ipc/ \"node-ipc documentation\"). A prettier version of this site.\r\n* [NPM Module](https://www.npmjs.org/package/node-ipc \"node-ipc npm module\"). The npm page for the node-ipc module.\r\n\r\nThis work is licenced via the [DBAD Public Licence](http://www.dbad-license.org/).\r\n\r\n----\r\n#### Contents\r\n\r\n1. [Types of IPC Sockets and Supporting OS](#types-of-ipc-sockets)\r\n2. [IPC Methods](#ipc-methods)\r\n 1. [log](#log)\r\n 2. [connectTo](#connectto)\r\n 3. [connectToNet](#connecttonet)\r\n 4. [disconnect](#disconnect)\r\n 5. [serve](#serve)\r\n 6. [serveNet](#servenet)\r\n3. [IPC Stores and Default Variables](#ipc-stores-and-default-variables)\r\n4. [Basic Examples](#basic-examples)\r\n 1. [Server for Unix||Windows Sockets & TCP Sockets](#server-for-unix-sockets--tcp-sockets)\r\n 2. [Client for Unix||Windows Sockets & TCP Sockets](#client-for-unix-sockets--tcp-sockets)\r\n 4. [Server & Client for UDP Sockets](#server--client-for-udp-sockets)\r\n 5. [Raw Buffers or Binary Sockets](#raw-buffer-or-binary-sockets)\r\n5. [Working with TLS/SSL Socket Servers & Clients](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket)\r\n6. [Advanced Examples](https://github.com/RIAEvangelist/node-ipc/tree/master/example)\r\n\r\n\r\n----\r\n#### Types of IPC Sockets\r\n\r\n| Type | Stability |Definition |\r\n|-----------|-----------|-----------|\r\n|Unix Socket or Windows Socket| Stable | Gives Linux, Mac, and Windows lightning fast communication and avoids the network card to reduce overhead and latency. [Local Unix and Windows Socket examples ](https://github.com/RIAEvangelist/node-ipc/tree/master/example/unixWindowsSocket/ \"Unix and Windows Socket Node IPC examples\") |\r\n|TCP Socket | Stable | Gives the most reliable communication across the network. Can be used for local IPC as well, but is slower than #1's Unix Socket Implementation because TCP sockets go through the network card while Unix Sockets and Windows Sockets do not. [Local or remote network TCP Socket examples ](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TCPSocket/ \"TCP Socket Node IPC examples\") |\r\n|TLS Socket | Stable | Configurable and secure network socket over SSL. Equivalent to https. [TLS/SSL documentation](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket) |\r\n|UDP Sockets| Stable | Gives the **fastest network communication**. UDP is less reliable but much faster than TCP. It is best used for streaming non critical data like sound, video, or multiplayer game data as it can drop packets depending on network connectivity and other factors. UDP can be used for local IPC as well, but is slower than #1's Unix Socket or Windows Socket Implementation because UDP sockets go through the network card while Unix and Windows Sockets do not. [Local or remote network UDP Socket examples ](https://github.com/RIAEvangelist/node-ipc/tree/master/example/UDPSocket/ \"UDP Socket Node IPC examples\") | \r\n\r\n| OS | Supported Sockets |\r\n|-----|--------------------|\r\n|Linux| Unix, Posix, TCP, TLS, UDP|\r\n|Mac | Unix, Posix, TCP, TLS, UDP|\r\n|Win | Windows, TCP, TLS, UDP | \r\n\r\n----\r\n\r\n`ipc.config` \r\n\r\nSet these variables in the `ipc.config` scope to overwrite or set default values.\r\n\r\n```javascript\r\n\r\n {\r\n appspace : 'app.',\r\n socketRoot : '/tmp/',\r\n id : os.hostname(),\r\n networkHost : 'localhost', //should resolve to 127.0.0.1 or ::1 see the table below related to this\r\n networkPort : 8000,\r\n encoding : 'utf8',\r\n rawBuffer : false,\r\n silent : false,\r\n maxConnections : 100,\r\n retry : 500,\r\n maxRetries : false,\r\n stopRetrying : false\r\n }\r\n\r\n```\r\n\r\n| variable | documentation |\r\n|----------|---------------|\r\n| appspace | used for Unix Socket (Unix Domain Socket) namespacing. If not set specifically, the Unix Domain Socket will combine the socketRoot, appspace, and id to form the Unix Socket Path for creation or binding. This is available incase you have many apps running on your system, you may have several sockets with the same id, but if you change the appspace, you will still have app specic unique sockets.|\r\n| socketRoot| the directory in which to create or bind to a Unix Socket |\r\n| id | the id of this socket or service |\r\n| networkHost| the local or remote host on which TCP, TLS or UDP Sockets should connect |\r\n| networkPort| the default port on which TCP, TLS, or UDP sockets should connect |\r\n| encoding | the default encoding for data sent on sockets. Mostly used if rawBuffer is set to true. Valid values are : ` ascii` ` utf8 ` ` utf16le` ` ucs2` ` base64` ` hex ` .\r\n| rawBuffer| if true, data will be sent and received as a raw node ` Buffer ` __NOT__ an ` Object ` as JSON. This is great for Binary or hex IPC, and communicating with other processes in languages like C and C++ |\r\n| silent | turn on/off logging default is false which means logging is on |\r\n| maxConnections| this is the max number of connections allowed to a socket. It is currently only being set on Unix Sockets. Other Socket types are using the system defaults. |\r\n| retry | this is the time in milliseconds a client will wait before trying to reconnect to a server if the connection is lost. This does not effect UDP sockets since they do not have a client server relationship like Unix Sockets and TCP Sockets. |\r\n| maxRetries | if set, it represents the maximum number of retries after each disconnect before giving up and completely killing a specific connection |\r\n| stopRetrying| Defaults to false meaning clients will continue to retry to connect to servers indefinitely at the retry interval. If set to any number the client will stop retrying when that number is exceeded after each disconnect. If set to true in real time it will immediately stop trying to connect regardless of maxRetries. If set to 0, the client will ***NOT*** try to reconnect. |\r\n\r\n----\r\n\r\n#### IPC Methods \r\nThese methods are available in the IPC Scope. \r\n\r\n----\r\n##### log\r\n\r\n`ipc.log(a,b,c,d,e...);` \r\n\r\nipc.log will accept any number of arguments and if `ipc.config.silent` is not set, it will concat them all with a sincle space ' ' between them and then log them to the console. This is fast because it prevents any concatenation from happening if the ipc is set to silent. That way if you leave your logging in place it should not effect performance.\r\n\r\nThe log also supports [colors](https://github.com/Marak/colors.js) implementation. All of the available styles are supported and the theme styles are as follows :\r\n\r\n```javascript\r\n\r\n {\r\n good : 'green',\r\n notice : 'yellow',\r\n warn : 'red',\r\n error : 'redBG',\r\n debug : 'magenta',\r\n variable: 'cyan',\r\n data : 'blue'\r\n } \r\n\r\n```\r\n\r\nYou can override any of these settings by requireing colors and setting the theme as follows :\r\n\r\n```javascript\r\n\r\n var colors=require('colors');\r\n\r\n colors.setTheme(\r\n {\r\n good : 'zebra',\r\n notice : 'redBG',\r\n ...\r\n } \r\n );\r\n\r\n```\r\n\r\n----\r\n##### connectTo\r\n\r\n`ipc.connectTo(id,path,callback);` \r\n\r\nUsed for connecting as a client to local Unix Sockets and Windows Sockets. ***This is the fastst way for processes on the same machine to communicate*** because it bypasses the network card which TCP and UDP must both use.\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| id | required | is the string id of the socket being connected to. The socket with this id is added to the ipc.of object when created. |\r\n| path | optional | is the path of the Unix Domain Socket File, if the System is Windows, this will automatically be converted to an appropriate pipe with the same information as the Unix Domain Socket File. If not set this will default to ` ipc.config.socketRoot `+` ipc.config.appspace `+` id ` |\r\n| callback | optional | this is the function to execute when the socket has been created. |\r\n\r\n**examples** arguments can be ommitted so long as they are still in order.\r\n\r\n```javascript\r\n\r\n ipc.connectTo('world');\r\n\r\n```\r\n\r\nor using just an id and a callback\r\n\r\n```javascript\r\n\r\n ipc.connectTo(\r\n 'world',\r\n function(){\r\n ipc.of.world.on(\r\n 'hello',\r\n function(data){\r\n ipc.log(data.debug);\r\n //if data was a string, it would have the color set to the debug style applied to it\r\n }\r\n )\r\n }\r\n );\r\n\r\n```\r\n\r\nor explicitly setting the path\r\n\r\n```javascript\r\n\r\n ipc.connectTo(\r\n 'world',\r\n 'myapp.world'\r\n );\r\n\r\n```\r\n\r\nor explicitly setting the path with callback\r\n\r\n```javascript\r\n\r\n ipc.connectTo(\r\n 'world',\r\n 'myapp.world',\r\n function(){\r\n ...\r\n }\r\n );\r\n\r\n```\r\n\r\n----\r\n##### connectToNet\r\n\r\n`ipc.connectToNet(id,host,port,callback)` \r\n\r\nUsed to connect as a client to a TCP or [TLS socket](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket) via the network card. This can be local or remote, if local, it is recommended that you use the Unix and Windows Socket Implementaion of `connectTo` instead as it is much faster since it avoids the network card altogether.\r\n\r\nFor TLS and SSL Sockets see the [node-ipc TLS and SSL docs](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket). They have a few additional requirements, and things to know about and so have their own doc.\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| id | required | is the string id of the socket being connected to. For TCP & TLS sockets, this id is added to the `ipc.of` object when the socket is created with a reference to the socket. |\r\n| host | optional | is the host on which the TCP or TLS socket resides. This will default to `ipc.config.networkHost` if not specified. |\r\n| port | optional | the port on which the TCP or TLS socket resides. |\r\n| callback | optional | this is the function to execute when the socket has been created. |\r\n\r\n**examples** arguments can be ommitted so long as they are still in order. \r\nSo while the default is : (id,host,port,callback), the following examples will still work because they are still in order (id,port,callback) or (id,host,callback) or (id,port) etc.\r\n\r\n```javascript\r\n\r\n ipc.connectToNet('world');\r\n\r\n```\r\n\r\nor using just an id and a callback\r\n\r\n```javascript\r\n\r\n ipc.connectToNet(\r\n 'world',\r\n function(){\r\n ...\r\n }\r\n );\r\n\r\n```\r\n\r\nor explicitly setting the host and path\r\n\r\n```javascript\r\n\r\n ipc.connectToNet(\r\n 'world',\r\n 'myapp.com',serve(path,callback)\r\n 3435\r\n );\r\n\r\n```\r\n\r\nor only explicitly setting port and callback\r\n\r\n```javascript\r\n\r\n ipc.connectToNet(\r\n 'world',\r\n 3435,\r\n function(){\r\n ...\r\n }\r\n );\r\n\r\n```\r\n\r\n----\r\n##### disconnect\r\n\r\n`ipc.disconnect(id)` \r\n\r\nUsed to disconnect a client from a Unix, Windows, TCP or TLS socket. The socket and its refrence will be removed from memory and the `ipc.of` scope. This can be local or remote. UDP clients do not maintain connections and so there are no Clients and this method has no value to them.\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| id | required | is the string id of the socket from which to disconnect. |\r\n\r\n**examples**\r\n\r\n```javascript\r\n\r\n ipc.disconnect('world');\r\n\r\n```\r\n\r\n----\r\n##### serve\r\n`ipc.serve(path,callback);` \r\n\r\nUsed to create local Unix Socket Server or Windows Socket Server to which Clients can bind. The server can `emit` events to specific Client Sockets, or `broadcast` events to all known Client Sockets. \r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| path | optional | This is the path of the Unix Domain Socket File, if the System is Windows, this will automatically be converted to an appropriate pipe with the same information as the Unix Domain Socket File. If not set this will default to ` ipc.config.socketRoot `+` ipc.config.appspace `+` id ` |\r\n| callback | optional | This is a function to be called after the Server has started. This can also be done by binding an event to the start event like `ipc.server.on('start',function(){});` |\r\n\r\n***examples*** arguments can be omitted so long as they are still in order.\r\n\r\n```javascript\r\n\r\n ipc.serve();\r\n\r\n```\r\n\r\nor specifying callback\r\n\r\n```javascript\r\n\r\n ipc.serve(\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specify path\r\n\r\n```javascript\r\n\r\n ipc.serve(\r\n '/tmp/myapp.myservice'\r\n );\r\n\r\n```\r\n\r\nor specifying everything\r\n\r\n```javascript\r\n\r\n ipc.serve(\r\n '/tmp/myapp.myservice',\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\n---- \r\n##### serveNet\r\n\r\n`serveNet(host,port,UDPType,callback)`\r\n\r\nUsed to create TCP, TLS or UDP Socket Server to which Clients can bind or other servers can send data to. The server can `emit` events to specific Client Sockets, or `broadcast` events to all known Client Sockets.\r\n\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| host | optional | If not specified this defaults to the first address in os.networkInterfaces(). For TCP, TLS & UDP servers this is most likely going to be 127.0.0.1 or ::1 |\r\n| port | optional | The port on wunich the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified |\r\n| UDPType | optional | If set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set.\r\n| callback | optional | Function to be called when the server is created |\r\n\r\n***examples*** arguments can be ommitted solong as they are still in order.\r\n\r\ndefault tcp server\r\n\r\n```javascript\r\n\r\n ipc.serveNet();\r\n\r\n```\r\n\r\ndefault udp server\r\n\r\n```javascript\r\n\r\n ipc.serveNet('udp4');\r\n\r\n```\r\n\r\nor specifying TCP server with callback\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specifying UDP server with callback\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 'udp4',\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specify port\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 3435\r\n );\r\n\r\n```\r\n\r\nor specifying everything TCP\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 'MyMostAwesomeApp.com',\r\n 3435,\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specifying everything UDP\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 'MyMostAwesomeApp.com',\r\n 3435,\r\n 'udp4',\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\n----\r\n### IPC Stores and Default Variables \r\n\r\n| variable | definition |\r\n|-----------|------------|\r\n| ipc.of | This is where socket connection refrences will be stored when connecting to them as a client via the `ipc.connectTo` or `iupc.connectToNet`. They will be stored based on the ID used to create them, eg : ipc.of.mySocket|\r\n| ipc.server| This is a refrence to the server created by `ipc.serve` or `ipc.serveNet`|\r\n\r\n----\r\n### Basic Examples\r\nYou can find [Advanced Examples](https://github.com/RIAEvangelist/node-ipc/tree/master/example) in the examples folder. In the examples you will find more complex demos including multi client examples.\r\n\r\n#### Server for Unix Sockets, Windows Sockets & TCP Sockets\r\nThe server is the process keeping a socket for IPC open. Multiple sockets can connect to this server and talk to it. It can also broadcast to all clients or emit to a specific client. This is the most basic example which will work for local Unix and Windows Sockets as well as local or remote network TCP Sockets.\r\n\r\n```javascript\r\n\r\n var ipc=require('node-ipc');\r\n\r\n ipc.config.id = 'world';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.serve(\r\n function(){\r\n ipc.server.on(\r\n 'message',\r\n function(data,socket){\r\n ipc.log('got a message : '.debug, data);\r\n ipc.server.emit(\r\n socket,\r\n 'message',\r\n data+' world!'\r\n );\r\n }\r\n );\r\n }\r\n );\r\n\r\n ipc.server.start();\r\n\r\n```\r\n\r\n#### Client for Unix Sockets & TCP Sockets\r\nThe client connects to the servers socket for Inter Process Communication. The socket will receive events emitted to it specifically as well as events which are broadcast out on the socket by the server. This is the most basic example which will work for both local Unix Sockets and local or remote network TCP Sockets.\r\n\r\n```javascript\r\n\r\n var ipc=require('node-ipc');\r\n\r\n ipc.config.id = 'hello';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.connectTo(\r\n 'world',\r\n function(){\r\n ipc.of.world.on(\r\n 'connect',\r\n function(){\r\n ipc.log('## connected to world ##'.rainbow, ipc.config.delay);\r\n ipc.of.world.emit(\r\n 'message',\r\n 'hello'\r\n )\r\n }\r\n );\r\n ipc.of.world.on(\r\n 'disconnect',\r\n function(){\r\n ipc.log('disconnected from world'.notice);\r\n }\r\n );\r\n ipc.of.world.on(\r\n 'message',\r\n function(data){\r\n ipc.log('got a message from world : '.debug, data);\r\n }\r\n );\r\n }\r\n );\r\n\r\n```\r\n\r\n#### Server & Client for UDP Sockets\r\nUDP Sockets are different than Unix, Windows & TCP Sockets because they must be bound to a unique port on their machine to receive messages. For example, A TCP, Unix, or Windows Socket client could just connect to a separate TCP, Unix, or Windows Socket sever. That client could then exchange, both send and receive, data on the servers port or location. UDP Sockets can not do this. They must bind to a port to receive or send data. \r\n\r\nThis means a UDP Client and Server are the same thing because in order to receive data, a UDP Socket must have its own port to receive data on, and only one process can use this port at a time. It also means that in order to `emit` or `broadcast` data the UDP server will need to know the host and port of the Socket it intends to broadcast the data to.\r\n\r\nThis is the most basic example which will work for both local and remote UDP Sockets.\r\n\r\n##### UDP Server 1 - \"World\"\r\n\r\n```javascript\r\n\r\n var ipc=require('../../../node-ipc');\r\n\r\n ipc.config.id = 'world';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.serveNet(\r\n 'udp4',\r\n function(){\r\n console.log(123);\r\n ipc.server.on(\r\n 'message',\r\n function(data,socket){\r\n ipc.log('got a message from '.debug, data.from.variable ,' : '.debug, data.message.variable);\r\n ipc.server.emit(\r\n socket,\r\n 'message',\r\n {\r\n from : ipc.config.id,\r\n message : data.message+' world!'\r\n }\r\n );\r\n }\r\n );\r\n\r\n console.log(ipc.server);\r\n }\r\n );\r\n\r\n ipc.server.define.listen.message='This event type listens for message strings as value of data key.';\r\n\r\n ipc.server.start();\r\n\r\n```\r\n\r\n##### UDP Server 2 - \"Hello\"\r\n*note* we set the port here to 8001 because the world server is already using the default ipc.config.networkPort of 8000. So we can not bind to 8000 while world is using it.\r\n\r\n```javascript\r\n\r\n ipc.config.id = 'hello';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.serveNet(\r\n 8001,\r\n 'udp4',\r\n function(){\r\n ipc.server.on(\r\n 'message',\r\n function(data){\r\n ipc.log('got Data');\r\n ipc.log('got a message from '.debug, data.from.variable ,' : '.debug, data.message.variable);\r\n }\r\n );\r\n ipc.server.emit(\r\n {\r\n address : '127.0.0.1', //any hostname will work\r\n port : ipc.config.networkPort\r\n },\r\n 'message',\r\n {\r\n from : ipc.config.id,\r\n message : 'Hello'\r\n }\r\n );\r\n }\r\n );\r\n\r\n ipc.server.define.listen.message='This event type listens for message strings as value of data key.';\r\n\r\n ipc.server.start();\r\n\r\n```\r\n\r\n#### Raw Buffer or Binary Sockets\r\nBinary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is ***slightly*** different.\r\n\r\nWhen setting up a rawBuffer socket you must specify it as such :\r\n\r\n```javascript\r\n\r\n ipc.config.rawBuffer=true;\r\n\r\n```\r\n\r\nYou can also specify its encoding type. The default is ` utf8 `\r\n\r\n```javascript\r\n\r\n ipc.config.encoding='utf8';\r\n\r\n```\r\n\r\nemit string buffer :\r\n\r\n```javascript\r\n\r\n //server\r\n ipc.server.emit(\r\n socket,\r\n 'hello'\r\n );\r\n\r\n //client\r\n ipc.of.world.emit(\r\n 'hello'\r\n )\r\n\r\n```\r\n\r\nemit byte array buffer :\r\n\r\n```javascript\r\n\r\n //server\r\n ipc.server.emit(\r\n socket,\r\n [10,20,30]\r\n );\r\n\r\n //client\r\n ipc.server.emit(\r\n [10,20,30]\r\n );\r\n\r\n```\r\n\r\nemit hex array buffer :\r\n\r\n```javascript\r\n\r\n //server\r\n ipc.server.emit(\r\n socket,\r\n [0x05,0x6d,0x5c]\r\n );\r\n\r\n //client\r\n ipc.server.emit(\r\n [0x05,0x6d,0x5c]\r\n );\r\n\r\n```\r\n\r\n#### Licensed under DBAD license\r\nSee the [DBAD license](https://github.com/philsturgeon/dbad) in your language or our [licence.md](https://github.com/RIAEvangelist/node-phidget-API/blob/master/license.md) file.\r\n","google":"UA-48524110-1","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file +{ + "name": "Node-ipc", + "tagline": "Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS", + "body": "node-ipc\r\n================\r\n*a nodejs module for local and remote Inter Process Communication* with full support for Linux, Mac and Windows. It also supports all forms of socket communication from low level unix and windows sockets to UDP and secure TLS and TCP sockets.\r\n\r\nA great solution for complex multiprocess **Neural Networking** in Node.JS\r\n\r\n**npm install node-ipc**\r\n\r\n#### NPM Stats\r\n\r\nnpm info : [See npm trends and stats for node-ipc](http://npm-stat.com/charts.html?package=node-ipc&author=&from=&to=) \r\n[![NPM](https://nodei.co/npm/node-ipc.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/node-ipc/)\r\n[![Package Quality](http://npm.packagequality.com/badge/node-ipc.png)](http://packagequality.com/#?package=node-ipc) \r\n![node-ipc npm version](https://img.shields.io/npm/v/node-ipc.svg) ![supported node version for node-ipc](https://img.shields.io/node/v/node-ipc.svg) ![total npm downloads for node-ipc](https://img.shields.io/npm/dt/node-ipc.svg) ![monthly npm downloads for node-ipc](https://img.shields.io/npm/dm/node-ipc.svg) ![npm licence for node-ipc](https://img.shields.io/npm/l/node-ipc.svg)\r\n\r\n[![RIAEvangelist](https://avatars3.githubusercontent.com/u/369041?v=3&s=100)](https://github.com/RIAEvangelist)\r\n\r\nGitHub info : \r\n![node-ipc GitHub Release](https://img.shields.io/github/release/RIAEvangelist/node-ipc.svg) ![GitHub license node-ipc license](https://img.shields.io/github/license/RIAEvangelist/node-ipc.svg) ![open issues for node-ipc on GitHub](https://img.shields.io/github/issues/RIAEvangelist/node-ipc.svg)\r\n\r\nCodacy info : \r\n[![Codacy Badge](https://api.codacy.com/project/badge/grade/8e0294dff55f4ac1985c07b16f39d0a9)](https://www.codacy.com/app/RIAEvangelist/node-ipc) [![Codacy Badge](https://api.codacy.com/project/badge/coverage/8e0294dff55f4ac1985c07b16f39d0a9)](https://www.codacy.com/app/RIAEvangelist/node-ipc)\r\n\r\nPackage details websites :\r\n* [GitHub.io site](http://riaevangelist.github.io/node-ipc/ \"node-ipc documentation\"). A prettier version of this site.\r\n* [NPM Module](https://www.npmjs.org/package/node-ipc \"node-ipc npm module\"). The npm page for the node-ipc module.\r\n\r\nThis work is licenced via the [DBAD Public Licence](http://www.dbad-license.org/).\r\n\r\n#### Testing\r\n\r\n` npm test ` will run the jasmine tests with istanbul for node-ipc and generate a coverage report in the spec folder.\r\n\r\nYou may want to install jasmine and istanbul globally with ` sudo npm install -g jasmine istanbul `\r\n\r\n----\r\n#### Contents\r\n\r\n1. [Types of IPC Sockets and Supporting OS](#types-of-ipc-sockets)\r\n1. [IPC Config](#ipc-config)\r\n2. [IPC Methods](#ipc-methods)\r\n 1. [log](#log)\r\n 2. [connectTo](#connectto)\r\n 3. [connectToNet](#connecttonet)\r\n 4. [disconnect](#disconnect)\r\n 5. [serve](#serve)\r\n 6. [serveNet](#servenet)\r\n3. [IPC Stores and Default Variables](#ipc-stores-and-default-variables)\r\n4. [IPC Events](#ipc-events)\r\n5. [Multiple IPC instances](#multiple-ipc-instances)\r\n6. [Basic Examples](#basic-examples)\r\n 1. [Server for Unix||Windows Sockets & TCP Sockets](#server-for-unix-sockets--tcp-sockets)\r\n 2. [Client for Unix||Windows Sockets & TCP Sockets](#client-for-unix-sockets--tcp-sockets)\r\n 4. [Server & Client for UDP Sockets](#server--client-for-udp-sockets)\r\n 5. [Raw Buffers, Real Time and / or Binary Sockets](#raw-buffer-or-binary-sockets)\r\n7. [Working with TLS/SSL Socket Servers & Clients](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket)\r\n8. [Node Code Examples](https://github.com/RIAEvangelist/node-ipc/tree/master/example)\r\n\r\n\r\n----\r\n#### Types of IPC Sockets\r\n\r\n| Type | Stability |Definition |\r\n|-----------|-----------|-----------|\r\n|Unix Socket or Windows Socket| Stable | Gives Linux, Mac, and Windows lightning fast communication and avoids the network card to reduce overhead and latency. [Local Unix and Windows Socket examples ](https://github.com/RIAEvangelist/node-ipc/tree/master/example/unixWindowsSocket/ \"Unix and Windows Socket Node IPC examples\") |\r\n|TCP Socket | Stable | Gives the most reliable communication across the network. Can be used for local IPC as well, but is slower than #1's Unix Socket Implementation because TCP sockets go through the network card while Unix Sockets and Windows Sockets do not. [Local or remote network TCP Socket examples ](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TCPSocket/ \"TCP Socket Node IPC examples\") |\r\n|TLS Socket | Stable | Configurable and secure network socket over SSL. Equivalent to https. [TLS/SSL documentation](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket) |\r\n|UDP Sockets| Stable | Gives the **fastest network communication**. UDP is less reliable but much faster than TCP. It is best used for streaming non critical data like sound, video, or multiplayer game data as it can drop packets depending on network connectivity and other factors. UDP can be used for local IPC as well, but is slower than #1's Unix Socket or Windows Socket Implementation because UDP sockets go through the network card while Unix and Windows Sockets do not. [Local or remote network UDP Socket examples ](https://github.com/RIAEvangelist/node-ipc/tree/master/example/UDPSocket/ \"UDP Socket Node IPC examples\") | \r\n\r\n| OS | Supported Sockets |\r\n|-----|--------------------|\r\n|Linux| Unix, Posix, TCP, TLS, UDP|\r\n|Mac | Unix, Posix, TCP, TLS, UDP|\r\n|Win | Windows, TCP, TLS, UDP | \r\n\r\n----\r\n\r\n#### IPC Config\r\n\r\n`ipc.config` \r\n\r\nSet these variables in the `ipc.config` scope to overwrite or set default values.\r\n\r\n```javascript\r\n\r\n {\r\n appspace : 'app.',\r\n socketRoot : '/tmp/',\r\n id : os.hostname(),\r\n networkHost : 'localhost', //should resolve to 127.0.0.1 or ::1 see the table below related to this\r\n networkPort : 8000,\r\n encoding : 'utf8',\r\n rawBuffer : false,\r\n sync : false,\r\n silent : false,\r\n logInColor : true,\r\n logDepth : 5,\r\n maxConnections : 100,\r\n retry : 500,\r\n maxRetries : false,\r\n stopRetrying : false\r\n }\r\n\r\n```\r\n\r\n| variable | documentation |\r\n|----------|---------------|\r\n| appspace | used for Unix Socket (Unix Domain Socket) namespacing. If not set specifically, the Unix Domain Socket will combine the socketRoot, appspace, and id to form the Unix Socket Path for creation or binding. This is available incase you have many apps running on your system, you may have several sockets with the same id, but if you change the appspace, you will still have app specic unique sockets.|\r\n| socketRoot| the directory in which to create or bind to a Unix Socket |\r\n| id | the id of this socket or service |\r\n| networkHost| the local or remote host on which TCP, TLS or UDP Sockets should connect |\r\n| networkPort| the default port on which TCP, TLS, or UDP sockets should connect |\r\n| encoding | the default encoding for data sent on sockets. Mostly used if rawBuffer is set to true. Valid values are : ` ascii` ` utf8 ` ` utf16le` ` ucs2` ` base64` ` hex ` . |\r\n| rawBuffer| if true, data will be sent and received as a raw node ` Buffer ` __NOT__ an ` Object ` as JSON. This is great for Binary or hex IPC, and communicating with other processes in languages like C and C++ |\r\n| sync | synchronous requests. Clients will not send new requests until the server answers. |\r\n| silent | turn on/off logging default is false which means logging is on |\r\n| logInColor | turn on/off util.inspect colors for ipc.log |\r\n| logDepth | set the depth for util.inspect during ipc.log |\r\n| maxConnections| this is the max number of connections allowed to a socket. It is currently only being set on Unix Sockets. Other Socket types are using the system defaults. |\r\n| retry | this is the time in milliseconds a client will wait before trying to reconnect to a server if the connection is lost. This does not effect UDP sockets since they do not have a client server relationship like Unix Sockets and TCP Sockets. |\r\n| maxRetries | if set, it represents the maximum number of retries after each disconnect before giving up and completely killing a specific connection |\r\n| stopRetrying| Defaults to false meaning clients will continue to retry to connect to servers indefinitely at the retry interval. If set to any number the client will stop retrying when that number is exceeded after each disconnect. If set to true in real time it will immediately stop trying to connect regardless of maxRetries. If set to 0, the client will ***NOT*** try to reconnect. |\r\n\r\n----\r\n\r\n#### IPC Methods \r\nThese methods are available in the IPC Scope. \r\n\r\n----\r\n##### log\r\n\r\n`ipc.log(a,b,c,d,e...);` \r\n\r\nipc.log will accept any number of arguments and if `ipc.config.silent` is not set, it will concat them all with a single space ' ' between them and then log them to the console. This is fast because it prevents any concatenation from happening if the ipc.config.silent is set ` true `. That way if you leave your logging in place it should have almost no effect on performance.\r\n\r\nThe log also uses util.inspect You can control if it should log in color as well as the log depth via ` ipc.config `\r\n\r\n```javascript\r\n\r\n ipc.config.logInColor=true; //default\r\n ipc.config.logDepth=5; //default \r\n\r\n```\r\n\r\n----\r\n##### connectTo\r\n\r\n`ipc.connectTo(id,path,callback);` \r\n\r\nUsed for connecting as a client to local Unix Sockets and Windows Sockets. ***This is the fastest way for processes on the same machine to communicate*** because it bypasses the network card which TCP and UDP must both use.\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| id | required | is the string id of the socket being connected to. The socket with this id is added to the ipc.of object when created. |\r\n| path | optional | is the path of the Unix Domain Socket File, if the System is Windows, this will automatically be converted to an appropriate pipe with the same information as the Unix Domain Socket File. If not set this will default to ` ipc.config.socketRoot `+` ipc.config.appspace `+` id ` |\r\n| callback | optional | this is the function to execute when the socket has been created. |\r\n\r\n**examples** arguments can be ommitted so long as they are still in order.\r\n\r\n```javascript\r\n\r\n ipc.connectTo('world');\r\n\r\n```\r\n\r\nor using just an id and a callback\r\n\r\n```javascript\r\n\r\n ipc.connectTo(\r\n 'world',\r\n function(){\r\n ipc.of.world.on(\r\n 'hello',\r\n function(data){\r\n ipc.log(data.debug);\r\n //if data was a string, it would have the color set to the debug style applied to it\r\n }\r\n )\r\n }\r\n );\r\n\r\n```\r\n\r\nor explicitly setting the path\r\n\r\n```javascript\r\n\r\n ipc.connectTo(\r\n 'world',\r\n 'myapp.world'\r\n );\r\n\r\n```\r\n\r\nor explicitly setting the path with callback\r\n\r\n```javascript\r\n\r\n ipc.connectTo(\r\n 'world',\r\n 'myapp.world',\r\n function(){\r\n ...\r\n }\r\n );\r\n\r\n```\r\n\r\n----\r\n##### connectToNet\r\n\r\n`ipc.connectToNet(id,host,port,callback)` \r\n\r\nUsed to connect as a client to a TCP or [TLS socket](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket) via the network card. This can be local or remote, if local, it is recommended that you use the Unix and Windows Socket Implementaion of `connectTo` instead as it is much faster since it avoids the network card altogether.\r\n\r\nFor TLS and SSL Sockets see the [node-ipc TLS and SSL docs](https://github.com/RIAEvangelist/node-ipc/tree/master/example/TLSSocket). They have a few additional requirements, and things to know about and so have their own doc.\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| id | required | is the string id of the socket being connected to. For TCP & TLS sockets, this id is added to the `ipc.of` object when the socket is created with a reference to the socket. |\r\n| host | optional | is the host on which the TCP or TLS socket resides. This will default to `ipc.config.networkHost` if not specified. |\r\n| port | optional | the port on which the TCP or TLS socket resides. |\r\n| callback | optional | this is the function to execute when the socket has been created. |\r\n\r\n**examples** arguments can be ommitted so long as they are still in order. \r\nSo while the default is : (id,host,port,callback), the following examples will still work because they are still in order (id,port,callback) or (id,host,callback) or (id,port) etc.\r\n\r\n```javascript\r\n\r\n ipc.connectToNet('world');\r\n\r\n```\r\n\r\nor using just an id and a callback\r\n\r\n```javascript\r\n\r\n ipc.connectToNet(\r\n 'world',\r\n function(){\r\n ...\r\n }\r\n );\r\n\r\n```\r\n\r\nor explicitly setting the host and path\r\n\r\n```javascript\r\n\r\n ipc.connectToNet(\r\n 'world',\r\n 'myapp.com',serve(path,callback)\r\n 3435\r\n );\r\n\r\n```\r\n\r\nor only explicitly setting port and callback\r\n\r\n```javascript\r\n\r\n ipc.connectToNet(\r\n 'world',\r\n 3435,\r\n function(){\r\n ...\r\n }\r\n );\r\n\r\n```\r\n\r\n----\r\n##### disconnect\r\n\r\n`ipc.disconnect(id)` \r\n\r\nUsed to disconnect a client from a Unix, Windows, TCP or TLS socket. The socket and its refrence will be removed from memory and the `ipc.of` scope. This can be local or remote. UDP clients do not maintain connections and so there are no Clients and this method has no value to them.\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| id | required | is the string id of the socket from which to disconnect. |\r\n\r\n**examples**\r\n\r\n```javascript\r\n\r\n ipc.disconnect('world');\r\n\r\n```\r\n\r\n----\r\n##### serve\r\n`ipc.serve(path,callback);` \r\n\r\nUsed to create local Unix Socket Server or Windows Socket Server to which Clients can bind. The server can `emit` events to specific Client Sockets, or `broadcast` events to all known Client Sockets. \r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| path | optional | This is the path of the Unix Domain Socket File, if the System is Windows, this will automatically be converted to an appropriate pipe with the same information as the Unix Domain Socket File. If not set this will default to ` ipc.config.socketRoot `+` ipc.config.appspace `+` id ` |\r\n| callback | optional | This is a function to be called after the Server has started. This can also be done by binding an event to the start event like `ipc.server.on('start',function(){});` |\r\n\r\n***examples*** arguments can be omitted so long as they are still in order.\r\n\r\n```javascript\r\n\r\n ipc.serve();\r\n\r\n```\r\n\r\nor specifying callback\r\n\r\n```javascript\r\n\r\n ipc.serve(\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specify path\r\n\r\n```javascript\r\n\r\n ipc.serve(\r\n '/tmp/myapp.myservice'\r\n );\r\n\r\n```\r\n\r\nor specifying everything\r\n\r\n```javascript\r\n\r\n ipc.serve(\r\n '/tmp/myapp.myservice',\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\n---- \r\n##### serveNet\r\n\r\n`serveNet(host,port,UDPType,callback)`\r\n\r\nUsed to create TCP, TLS or UDP Socket Server to which Clients can bind or other servers can send data to. The server can `emit` events to specific Client Sockets, or `broadcast` events to all known Client Sockets.\r\n\r\n\r\n| variable | required | definition |\r\n|----------|----------|------------|\r\n| host | optional | If not specified this defaults to the first address in os.networkInterfaces(). For TCP, TLS & UDP servers this is most likely going to be 127.0.0.1 or ::1 |\r\n| port | optional | The port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified |\r\n| UDPType | optional | If set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set. When using udp6 make sure to specify a valid IPv6 host, like ` ::1 ` |\r\n| callback | optional | Function to be called when the server is created |\r\n\r\n***examples*** arguments can be ommitted solong as they are still in order.\r\n\r\ndefault tcp server\r\n\r\n```javascript\r\n\r\n ipc.serveNet();\r\n\r\n```\r\n\r\ndefault udp server\r\n\r\n```javascript\r\n\r\n ipc.serveNet('udp4');\r\n\r\n```\r\n\r\nor specifying TCP server with callback\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specifying UDP server with callback\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 'udp4',\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specify port\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 3435\r\n );\r\n\r\n```\r\n\r\nor specifying everything TCP\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 'MyMostAwesomeApp.com',\r\n 3435,\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\nor specifying everything UDP\r\n\r\n```javascript\r\n\r\n ipc.serveNet(\r\n 'MyMostAwesomeApp.com',\r\n 3435,\r\n 'udp4',\r\n function(){...}\r\n );\r\n\r\n```\r\n\r\n----\r\n### IPC Stores and Default Variables \r\n\r\n| variable | definition |\r\n|-----------|------------|\r\n| ipc.of | This is where socket connection refrences will be stored when connecting to them as a client via the `ipc.connectTo` or `iupc.connectToNet`. They will be stored based on the ID used to create them, eg : ipc.of.mySocket|\r\n| ipc.server| This is a refrence to the server created by `ipc.serve` or `ipc.serveNet`|\r\n\r\n----\r\n### IPC Server Methods \r\n\r\n| method | definition |\r\n|-----------|------------|\r\n|start| start serving need top call ` serve ` or ` serveNet ` first to set up the server |\r\n|stop| close the server and stop serving |\r\n\r\n----\r\n\r\n### IPC Events \r\n\r\n|event name|params|definition|\r\n|----------|------|----------|\r\n|error|err obj|triggered when an error has occured|\r\n|connect||triggered when socket connected|\r\n|disconnect||triggered when socket disconnected|\r\n|destroy||triggered when socket has been totally destroyed, no further auto retries will happen and all references are gone.|\r\n|data|buffer|triggered when ipc.config.rawBuffer is true and a message is received.|\r\n|***your event type***|***your event data***|triggered when a JSON message is received. The event name will be the type string from your message and the param will be the data object from your message eg : ` { type:'myEvent',data:{a:1}} ` |\r\n||||\r\n\r\n### Multiple IPC Instances\r\n\r\nSometimes you might need explicit and independent instances of node-ipc. Just for such scenarios we have exposed the core IPC class on the IPC singleton.\r\n\r\n```javascript\r\n\r\n const RawIPC=require('node-ipc').IPC;\r\n const ipc=new RawIPC;\r\n const someOtherExplicitIPC=new RawIPC;\r\n\r\n\r\n //OR\r\n\r\n const ipc=require('node-ipc');\r\n const someOtherExplicitIPC=new ipc.IPC;\r\n\r\n\r\n //setting explicit configs\r\n\r\n //keep one silent and the other verbose\r\n ipc.config.silent=true;\r\n someOtherExplicitIPC.config.silent=true;\r\n\r\n //make one a raw binary and the other json based ipc\r\n ipc.config.rawBuffer=false;\r\n\r\n someOtherExplicitIPC.config.rawBuffer=true;\r\n someOtherExplicitIPC.config.encoding='hex';\r\n\r\n```\r\n\r\n\r\n----\r\n### Basic Examples\r\nYou can find [Advanced Examples](https://github.com/RIAEvangelist/node-ipc/tree/master/example) in the examples folder. In the examples you will find more complex demos including multi client examples.\r\n\r\n#### Server for Unix Sockets, Windows Sockets & TCP Sockets\r\nThe server is the process keeping a socket for IPC open. Multiple sockets can connect to this server and talk to it. It can also broadcast to all clients or emit to a specific client. This is the most basic example which will work for local Unix and Windows Sockets as well as local or remote network TCP Sockets.\r\n\r\n```javascript\r\n\r\n var ipc=require('node-ipc');\r\n\r\n ipc.config.id = 'world';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.serve(\r\n function(){\r\n ipc.server.on(\r\n 'message',\r\n function(data,socket){\r\n ipc.log('got a message : '.debug, data);\r\n ipc.server.emit(\r\n socket,\r\n 'message', //this can be anything you want so long as\r\n //your client knows.\r\n data+' world!'\r\n );\r\n }\r\n );\r\n }\r\n );\r\n\r\n ipc.server.start();\r\n\r\n```\r\n\r\n#### Client for Unix Sockets & TCP Sockets\r\nThe client connects to the servers socket for Inter Process Communication. The socket will receive events emitted to it specifically as well as events which are broadcast out on the socket by the server. This is the most basic example which will work for both local Unix Sockets and local or remote network TCP Sockets.\r\n\r\n```javascript\r\n\r\n var ipc=require('node-ipc');\r\n\r\n ipc.config.id = 'hello';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.connectTo(\r\n 'world',\r\n function(){\r\n ipc.of.world.on(\r\n 'connect',\r\n function(){\r\n ipc.log('## connected to world ##'.rainbow, ipc.config.delay);\r\n ipc.of.world.emit(\r\n 'message', //any event or message type your server listens for\r\n 'hello'\r\n )\r\n }\r\n );\r\n ipc.of.world.on(\r\n 'disconnect',\r\n function(){\r\n ipc.log('disconnected from world'.notice);\r\n }\r\n );\r\n ipc.of.world.on(\r\n 'message', //any event or message type your server listens for\r\n function(data){\r\n ipc.log('got a message from world : '.debug, data);\r\n }\r\n );\r\n }\r\n );\r\n\r\n```\r\n\r\n#### Server & Client for UDP Sockets\r\nUDP Sockets are different than Unix, Windows & TCP Sockets because they must be bound to a unique port on their machine to receive messages. For example, A TCP, Unix, or Windows Socket client could just connect to a separate TCP, Unix, or Windows Socket sever. That client could then exchange, both send and receive, data on the servers port or location. UDP Sockets can not do this. They must bind to a port to receive or send data. \r\n\r\nThis means a UDP Client and Server are the same thing because in order to receive data, a UDP Socket must have its own port to receive data on, and only one process can use this port at a time. It also means that in order to `emit` or `broadcast` data the UDP server will need to know the host and port of the Socket it intends to broadcast the data to.\r\n\r\nThis is the most basic example which will work for both local and remote UDP Sockets.\r\n\r\n##### UDP Server 1 - \"World\"\r\n\r\n```javascript\r\n\r\n var ipc=require('../../../node-ipc');\r\n\r\n ipc.config.id = 'world';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.serveNet(\r\n 'udp4',\r\n function(){\r\n console.log(123);\r\n ipc.server.on(\r\n 'message',\r\n function(data,socket){\r\n ipc.log('got a message from '.debug, data.from.variable ,' : '.debug, data.message.variable);\r\n ipc.server.emit(\r\n socket,\r\n 'message',\r\n {\r\n from : ipc.config.id,\r\n message : data.message+' world!'\r\n }\r\n );\r\n }\r\n );\r\n\r\n console.log(ipc.server);\r\n }\r\n );\r\n\r\n ipc.server.start();\r\n\r\n```\r\n\r\n##### UDP Server 2 - \"Hello\"\r\n*note* we set the port here to 8001 because the world server is already using the default ipc.config.networkPort of 8000. So we can not bind to 8000 while world is using it.\r\n\r\n```javascript\r\n\r\n ipc.config.id = 'hello';\r\n ipc.config.retry= 1500;\r\n\r\n ipc.serveNet(\r\n 8001,\r\n 'udp4',\r\n function(){\r\n ipc.server.on(\r\n 'message',\r\n function(data){\r\n ipc.log('got Data');\r\n ipc.log('got a message from '.debug, data.from.variable ,' : '.debug, data.message.variable);\r\n }\r\n );\r\n ipc.server.emit(\r\n {\r\n address : '127.0.0.1', //any hostname will work\r\n port : ipc.config.networkPort\r\n },\r\n 'message',\r\n {\r\n from : ipc.config.id,\r\n message : 'Hello'\r\n }\r\n );\r\n }\r\n );\r\n\r\n ipc.server.start();\r\n\r\n```\r\n\r\n#### Raw Buffer or Binary Sockets\r\nBinary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is ***slightly*** different. These may come in handy if working with embedded systems or C / C++ processes. You can even make sure to match C or C++ string typing.\r\n\r\nWhen setting up a rawBuffer socket you must specify it as such :\r\n\r\n```javascript\r\n\r\n ipc.config.rawBuffer=true;\r\n\r\n```\r\n\r\nYou can also specify its encoding type. The default is ` utf8 `\r\n\r\n```javascript\r\n\r\n ipc.config.encoding='utf8';\r\n\r\n```\r\n\r\nemit string buffer :\r\n\r\n```javascript\r\n\r\n //server\r\n ipc.server.emit(\r\n socket,\r\n 'hello'\r\n );\r\n\r\n //client\r\n ipc.of.world.emit(\r\n 'hello'\r\n )\r\n\r\n```\r\n\r\nemit byte array buffer :\r\n\r\n```javascript\r\n\r\n //hex encoding may work best for this.\r\n ipc.config.encoding='hex';\r\n\r\n //server\r\n ipc.server.emit(\r\n socket,\r\n [10,20,30]\r\n );\r\n\r\n //client\r\n ipc.server.emit(\r\n [10,20,30]\r\n );\r\n\r\n```\r\n\r\nemit binary or hex array buffer, this is best for real time data transfer, especially whan connecting to C or C++ processes, or embedded systems :\r\n\r\n```javascript\r\n\r\n ipc.config.encoding='hex';\r\n\r\n //server\r\n ipc.server.emit(\r\n socket,\r\n [0x05,0x6d,0x5c]\r\n );\r\n\r\n //client\r\n ipc.server.emit(\r\n [0x05,0x6d,0x5c]\r\n );\r\n\r\n```\r\n\r\nWriting explicit buffers, int types, doubles, floats etc. as well as big endian and little endian data to raw buffer nostly valuable when connecting to C or C++ processes, or embedded systems (see more detailed info on buffers as well as UInt, Int, double etc. here)[https://nodejs.org/api/buffer.html]:\r\n\r\n```javascript\r\n\r\n ipc.config.encoding='hex';\r\n\r\n //make a 6 byte buffer for example\r\n const myBuffer=new Buffer(6).fill(0);\r\n\r\n //fill the first 2 bytes with a 16 bit (2 byte) short unsigned int\r\n\r\n //write a UInt16 (2 byte or short) as Big Endian\r\n myBuffer.writeUInt16BE(\r\n 2, //value to write\r\n 0 //offset in bytes\r\n );\r\n //OR\r\n myBuffer.writeUInt16LE(0x2,0);\r\n //OR\r\n myBuffer.writeUInt16LE(0x02,0);\r\n\r\n //fill the remaining 4 bytes with a 32 bit (4 byte) long unsigned int\r\n\r\n //write a UInt32 (4 byte or long) as Big Endian\r\n myBuffer.writeUInt32BE(\r\n 16772812, //value to write\r\n 2 //offset in bytes\r\n );\r\n //OR\r\n myBuffer.writeUInt32BE(0xffeecc,0)\r\n\r\n //server\r\n ipc.server.emit(\r\n socket,\r\n myBuffer\r\n );\r\n\r\n //client\r\n ipc.server.emit(\r\n myBuffer\r\n );\r\n\r\n```\r\n\r\n#### Licensed under DBAD license\r\nSee the [DBAD license](https://github.com/philsturgeon/dbad) in your language or our [licence.md](https://github.com/RIAEvangelist/node-phidget-API/blob/master/license.md) file.\r\n", + "google": "UA-48524110-1", + "note": "Don't delete this file! It's used internally to help with page regeneration." +} \ No newline at end of file