Create gh-pages branch via GitHub

This commit is contained in:
Brandon Nozaki Miller 2015-09-27 05:06:15 -07:00
parent 978b918b6c
commit 810e9e216e
4 changed files with 229 additions and 45 deletions

View file

@ -34,12 +34,18 @@
<h1> <h1>
<a id="node-ipc" class="anchor" href="#node-ipc" aria-hidden="true"><span class="octicon octicon-link"></span></a>node-ipc</h1> <a id="node-ipc" class="anchor" href="#node-ipc" aria-hidden="true"><span class="octicon octicon-link"></span></a>node-ipc</h1>
<p><em>a nodejs module for local and remote Inter Process Communication</em> for Linux, Mac and Windows.<br> <p><em>a nodejs module for local and remote Inter Process Communication</em> with full support for Linux, Mac and Windows.<br>
A great solution for <strong>Neural Networking</strong> in Node.JS</p> A great solution for <strong>Neural Networking</strong> in Node.JS</p>
<p><strong>npm install node-ipc</strong><br> <p><strong>npm install node-ipc</strong></p>
<img src="https://nodei.co/npm/node-ipc.png?downloads=true&amp;downloadRank=true&amp;stars=true" alt="NPM Stats for node-ipc">
<img src="https://nodei.co/npm-dl/node-ipc.png?months=6&amp;height=3" alt="NPM Download Graph for node-ipc"></p> <p>npm info : <a href="http://npm-stat.com/charts.html?package=node-ipc&amp;author=&amp;from=&amp;to=">See npm trends and stats for node-ipc</a><br>
<img src="https://img.shields.io/npm/v/node-ipc.svg" alt="node-ipc npm version"> <img src="https://img.shields.io/node/v/node-ipc.svg" alt="supported node version for node-ipc"> <img src="https://img.shields.io/npm/dt/node-ipc.svg" alt="total npm downloads for node-ipc"> <img src="https://img.shields.io/npm/dm/node-ipc.svg" alt="monthly npm downloads for node-ipc"> <img src="https://img.shields.io/npm/l/node-ipc.svg" alt="npm licence for node-ipc"></p>
<p><a href="https://github.com/RIAEvangelist"><img src="https://avatars3.githubusercontent.com/u/369041?v=3&amp;s=100" alt="RIAEvangelist"></a></p>
<p>GitHub info :<br>
<img src="https://img.shields.io/github/release/RIAEvangelist/node-ipc.svg" alt="node-ipc GitHub Release"> <img src="https://img.shields.io/github/license/RIAEvangelist/node-ipc.svg" alt="GitHub license node-ipc license"> <img src="https://img.shields.io/github/issues/RIAEvangelist/node-ipc.svg" alt="open issues for node-ipc on GitHub"></p>
<p>Package details websites :</p> <p>Package details websites :</p>
@ -50,7 +56,7 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
<a href="https://www.npmjs.org/package/node-ipc" title="node-ipc npm module">NPM Module</a>. The npm page for the node-ipc module.</li> <a href="https://www.npmjs.org/package/node-ipc" title="node-ipc npm module">NPM Module</a>. The npm page for the node-ipc module.</li>
</ul> </ul>
<p>This work is licenced via the <a href="http://www.dbad-license.org/">DBAD Public Licence</a>. </p> <p>This work is licenced via the <a href="http://www.dbad-license.org/">DBAD Public Licence</a>.</p>
<hr> <hr>
@ -76,8 +82,8 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
<a href="#basic-examples">Basic Examples</a> <a href="#basic-examples">Basic Examples</a>
<ol> <ol>
<li><a href="#server-for-unix-sockets--tcp-sockets">Server for Unix Sockets &amp; TCP Sockets</a></li> <li><a href="#server-for-unix-sockets--tcp-sockets">Server for Unix||Windows Sockets &amp; TCP Sockets</a></li>
<li><a href="#client-for-unix-sockets--tcp-sockets">Client for Unix Sockets &amp; TCP Sockets</a></li> <li><a href="#client-for-unix-sockets--tcp-sockets">Client for Unix||Windows Sockets &amp; TCP Sockets</a></li>
<li><a href="#server--client-for-udp-sockets">Server &amp; Client for UDP Sockets</a></li> <li><a href="#server--client-for-udp-sockets">Server &amp; Client for UDP Sockets</a></li>
</ol> </ol>
</li> </li>
@ -99,15 +105,15 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>Unix Socket</td> <td>Unix Socket or Windows Socket</td>
<td>Stable</td> <td>Stable</td>
<td>Gives Linux and Mac lightning fast communication and avoids the network card to reduce overhead and latency. <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example/unixSocket/" title="Unix Socket Node IPC examples">Local Unix Socket examples </a> <td>Gives Linux, Mac, and Windows lightning fast communication and avoids the network card to reduce overhead and latency. <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example/unixWindowsSocket/" title="Unix and Windows Socket Node IPC examples">Local Unix and Windows Socket examples </a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>TCP Socket</td> <td>TCP Socket</td>
<td>Stable</td> <td>Stable</td>
<td>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 do not. <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example/TCPSocket/" title="TCP Socket Node IPC examples">Local or remote network TCP Socket examples </a> <td>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. <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example/TCPSocket/" title="TCP Socket Node IPC examples">Local or remote network TCP Socket examples </a>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -118,7 +124,7 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
<tr> <tr>
<td>UDP Sockets</td> <td>UDP Sockets</td>
<td>Stable</td> <td>Stable</td>
<td>Gives the <strong>fastest network communication</strong>. 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 Implementation because UDP sockets go through the network card while Unix Sockets do not. <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example/UDPSocket/" title="UDP Socket Node IPC examples">Local or remote network UDP Socket examples </a> <td>Gives the <strong>fastest network communication</strong>. 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. <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example/UDPSocket/" title="UDP Socket Node IPC examples">Local or remote network UDP Socket examples </a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -134,21 +140,19 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
<tbody> <tbody>
<tr> <tr>
<td>Linux</td> <td>Linux</td>
<td>Unix, TCP, TLS, UDP</td> <td>Unix, Posix, TCP, TLS, UDP</td>
</tr> </tr>
<tr> <tr>
<td>Mac</td> <td>Mac</td>
<td>Unix, TCP, TLS, UDP</td> <td>Unix, Posix, TCP, TLS, UDP</td>
</tr> </tr>
<tr> <tr>
<td>Win</td> <td>Win</td>
<td>TCP, TLS, UDP</td> <td>Windows, TCP, TLS, UDP</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p><strong>Windows</strong> users may want to use UDP servers for the fastest local IPC. Unix Servers are the fastest oprion on Linux and Mac, but not available for windows. </p>
<hr> <hr>
<p><code>ipc.config</code> </p> <p><code>ipc.config</code> </p>
@ -159,9 +163,10 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
appspace : 'app.', appspace : 'app.',
socketRoot : '/tmp/', socketRoot : '/tmp/',
id : os.hostname(), id : os.hostname(),
networkHost : 'localhost', networkHost : 'localhost', //should resolve to 127.0.0.1 or ::1 see the table below related to this
networkPort : 8000, networkPort : 8000,
encoding : 'utf8', encoding : 'utf8',
rawBuffer : false,
silent : false, silent : false,
maxConnections : 100, maxConnections : 100,
retry : 500, retry : 500,
@ -200,7 +205,11 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
</tr> </tr>
<tr> <tr>
<td>encoding</td> <td>encoding</td>
<td>the default encoding for data sent on sockets</td> <td>the default encoding for data sent on sockets. Mostly used if rawBuffer is set to true. Valid values are : <code>ascii</code> <code>utf8</code> <code>utf16le</code> <code>ucs2</code> <code>base64</code> <code>hex</code> .</td>
</tr>
<tr>
<td>rawBuffer</td>
<td>if true, data will be sent and received as a raw node <code>Buffer</code> <strong>NOT</strong> an <code>Object</code> as JSON. This is great for Binary or hex IPC, and communicating with other processes in languages like C and C++</td>
</tr> </tr>
<tr> <tr>
<td>silent</td> <td>silent</td>
@ -220,7 +229,7 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
</tr> </tr>
<tr> <tr>
<td>stopRetrying</td> <td>stopRetrying</td>
<td>Defaults to false mwaning clients will continue to retryt to connect to servers indefinately 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 0, the client will <strong><em>NOT</em></strong> try to reconnect.</td> <td>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 0, the client will <strong><em>NOT</em></strong> try to reconnect.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -239,9 +248,9 @@ A great solution for <strong>Neural Networking</strong> in Node.JS</p>
<p><code>ipc.log(a,b,c,d,e...);</code> </p> <p><code>ipc.log(a,b,c,d,e...);</code> </p>
<p>ipc.log will accept any number of arguments and if <code>ipc.config.silent</code> 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 concation from happening if the ipc is set to silent. That way if you leave your logging in place it should not effect performance.</p> <p>ipc.log will accept any number of arguments and if <code>ipc.config.silent</code> 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.</p>
<p>the log also supports <a href="https://github.com/Marak/colors.js">colors</a> implementation. All of the available styles are supported and the theme styles are as follows :</p> <p>The log also supports <a href="https://github.com/Marak/colors.js">colors</a> implementation. All of the available styles are supported and the theme styles are as follows :</p>
<pre><code>{ <pre><code>{
good : 'green', good : 'green',
@ -274,7 +283,7 @@ colors.setTheme(
<p><code>ipc.connectTo(id,path,callback);</code> </p> <p><code>ipc.connectTo(id,path,callback);</code> </p>
<p>Used for connecting as a client to local Unix Sockets. <strong><em>This is the fastst way for processes on the same machine to communicate</em></strong> because it bypasses the network card which TCP and UDP must both use.</p> <p>Used for connecting as a client to local Unix Sockets and Windows Sockets. <strong><em>This is the fastst way for processes on the same machine to communicate</em></strong> because it bypasses the network card which TCP and UDP must both use.</p>
<table> <table>
<thead> <thead>
@ -293,7 +302,7 @@ colors.setTheme(
<tr> <tr>
<td>path</td> <td>path</td>
<td>optional</td> <td>optional</td>
<td>is the path of the Unix Domain Socket File, if not set this will be defaylted to <code>ipc.config.socketRoot</code>+<code>ipc.config.appspace</code>+<code>id</code> <td>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 <code>ipc.config.socketRoot</code>+<code>ipc.config.appspace</code>+<code>id</code>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -304,7 +313,7 @@ colors.setTheme(
</tbody> </tbody>
</table> </table>
<p><strong>examples</strong> arguments can be ommitted solong as they are still in order.</p> <p><strong>examples</strong> arguments can be ommitted so long as they are still in order.</p>
<pre><code>ipc.connectTo('world'); <pre><code>ipc.connectTo('world');
</code></pre> </code></pre>
@ -351,7 +360,7 @@ colors.setTheme(
<p><code>ipc.connectToNet(id,host,port,callback)</code> </p> <p><code>ipc.connectToNet(id,host,port,callback)</code> </p>
<p>Used to connect as a client to a TCP or TLS socket via the network card. This can be local or remote, if local, it is recommended that you use the Unix Socket Implementaion of <code>connectTo</code> instead as it is much faster since it avoids the network card alltogether.</p> <p>Used to connect as a client to a TCP or TLS socket 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 <code>connectTo</code> instead as it is much faster since it avoids the network card altogether.</p>
<table> <table>
<thead> <thead>
@ -365,7 +374,7 @@ colors.setTheme(
<tr> <tr>
<td>id</td> <td>id</td>
<td>required</td> <td>required</td>
<td>is the string id of the socket being connected to. For TCP &amp; TLS sockets, this id is added to the <code>ipc.of</code> object when the socket is created with a refrence to the socket.</td> <td>is the string id of the socket being connected to. For TCP &amp; TLS sockets, this id is added to the <code>ipc.of</code> object when the socket is created with a reference to the socket.</td>
</tr> </tr>
<tr> <tr>
<td>host</td> <td>host</td>
@ -385,7 +394,7 @@ colors.setTheme(
</tbody> </tbody>
</table> </table>
<p><strong>examples</strong> arguments can be ommitted solong as they are still in order.<br> <p><strong>examples</strong> arguments can be ommitted so long as they are still in order.<br>
So 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.</p> So 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.</p>
<pre><code>ipc.connectToNet('world'); <pre><code>ipc.connectToNet('world');
@ -428,7 +437,7 @@ So while the default is : (id,host,port,callback), the following examples will s
<p><code>ipc.disconnect(id)</code> </p> <p><code>ipc.disconnect(id)</code> </p>
<p>Used to disconnect a client from a Unix, TCP or TLS socket. The socket and its refrence will be removed from memory and the <code>ipc.of</code> 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.</p> <p>Used to disconnect a client from a Unix, Windows, TCP or TLS socket. The socket and its refrence will be removed from memory and the <code>ipc.of</code> 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.</p>
<table> <table>
<thead> <thead>
@ -459,7 +468,7 @@ So while the default is : (id,host,port,callback), the following examples will s
<p><code>ipc.serve(path,callback);</code> </p> <p><code>ipc.serve(path,callback);</code> </p>
<p>Used to create local Unix Socket Server to which Clients can bind. The server can <code>emit</code> events to specific Client Sockets, or <code>broadcast</code> events to all known Client Sockets. </p> <p>Used to create local Unix Socket Server or Windows Socket Server to which Clients can bind. The server can <code>emit</code> events to specific Client Sockets, or <code>broadcast</code> events to all known Client Sockets. </p>
<table> <table>
<thead> <thead>
@ -473,7 +482,8 @@ So while the default is : (id,host,port,callback), the following examples will s
<tr> <tr>
<td>path</td> <td>path</td>
<td>optional</td> <td>optional</td>
<td>This is the Unix Domain Socket path to bind to. If not supplied, it will default to : ipc.config.socketRoot + ipc.config.appspace + ipc.config.id;</td> <td>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 <code>ipc.config.socketRoot</code>+<code>ipc.config.appspace</code>+<code>id</code>
</td>
</tr> </tr>
<tr> <tr>
<td>callback</td> <td>callback</td>
@ -484,7 +494,7 @@ So while the default is : (id,host,port,callback), the following examples will s
</tbody> </tbody>
</table> </table>
<p><strong><em>examples</em></strong> arguments can be ommitted solong as they are still in order.</p> <p><strong><em>examples</em></strong> arguments can be omitted so long as they are still in order.</p>
<pre><code>ipc.serve(); <pre><code>ipc.serve();
</code></pre> </code></pre>
@ -518,7 +528,7 @@ So while the default is : (id,host,port,callback), the following examples will s
<p><code>serveNet(host,port,UDPType,callback)</code></p> <p><code>serveNet(host,port,UDPType,callback)</code></p>
<p>Used to create TCP, TLS or UDP Socket Server to which Clients can bind or other servers can send data to. The server can <code>emit</code> events to specific Client Sockets, or <code>broadcast</code> events to all known Client Sockets. </p> <p>Used to create TCP, TLS or UDP Socket Server to which Clients can bind or other servers can send data to. The server can <code>emit</code> events to specific Client Sockets, or <code>broadcast</code> events to all known Client Sockets.</p>
<table> <table>
<thead> <thead>
@ -532,12 +542,12 @@ So while the default is : (id,host,port,callback), the following examples will s
<tr> <tr>
<td>host</td> <td>host</td>
<td>optional</td> <td>optional</td>
<td>If not specified this defaults to localhost. For TCP, TLS &amp; UDP servers this is most likely going to be localhost or 0.0.0.0 unless you have something like <a href="https://github.com/RIAEvangelist/node-http-server">node-http-server</a> installed to run subdomains for you.</td> <td>If not specified this defaults to the first address in os.networkInterfaces(). For TCP, TLS &amp; UDP servers this is most likely going to be 127.0.0.1 or ::1</td>
</tr> </tr>
<tr> <tr>
<td>port</td> <td>port</td>
<td>optional</td> <td>optional</td>
<td>The port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified</td> <td>The port on wunich the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified</td>
</tr> </tr>
<tr> <tr>
<td>UDPType</td> <td>UDPType</td>
@ -638,9 +648,9 @@ So while the default is : (id,host,port,callback), the following examples will s
<p>You can find <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example">Advanced Examples</a> in the examples folder. In the examples you will find more complex demos including multi client examples.</p> <p>You can find <a href="https://github.com/RIAEvangelist/node-ipc/tree/master/example">Advanced Examples</a> in the examples folder. In the examples you will find more complex demos including multi client examples.</p>
<h4> <h4>
<a id="server-for-unix-sockets--tcp-sockets" class="anchor" href="#server-for-unix-sockets--tcp-sockets" aria-hidden="true"><span class="octicon octicon-link"></span></a>Server for Unix Sockets &amp; TCP Sockets</h4> <a id="server-for-unix-sockets-windows-sockets--tcp-sockets" class="anchor" href="#server-for-unix-sockets-windows-sockets--tcp-sockets" aria-hidden="true"><span class="octicon octicon-link"></span></a>Server for Unix Sockets, Windows Sockets &amp; TCP Sockets</h4>
<p>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 both local Unix Sockets and local or remote network TCP Sockets.</p> <p>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.</p>
<pre><code>var ipc=require('node-ipc'); <pre><code>var ipc=require('node-ipc');
@ -654,6 +664,7 @@ ipc.serve(
function(data,socket){ function(data,socket){
ipc.log('got a message : '.debug, data); ipc.log('got a message : '.debug, data);
ipc.server.emit( ipc.server.emit(
socket,
'message', 'message',
data+' world!' data+' world!'
); );
@ -668,9 +679,9 @@ ipc.server.start();
<h4> <h4>
<a id="client-for-unix-sockets--tcp-sockets" class="anchor" href="#client-for-unix-sockets--tcp-sockets" aria-hidden="true"><span class="octicon octicon-link"></span></a>Client for Unix Sockets &amp; TCP Sockets</h4> <a id="client-for-unix-sockets--tcp-sockets" class="anchor" href="#client-for-unix-sockets--tcp-sockets" aria-hidden="true"><span class="octicon octicon-link"></span></a>Client for Unix Sockets &amp; TCP Sockets</h4>
<p>The client connects to the servers socket for Inter Process Communication. The socket will recieve 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.</p> <p>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.</p>
<pre><code>var ipc=require('../../../node-ipc'); <pre><code>var ipc=require('node-ipc');
ipc.config.id = 'hello'; ipc.config.id = 'hello';
ipc.config.retry= 1500; ipc.config.retry= 1500;
@ -707,11 +718,11 @@ ipc.connectTo(
<h4> <h4>
<a id="server--client-for-udp-sockets" class="anchor" href="#server--client-for-udp-sockets" aria-hidden="true"><span class="octicon octicon-link"></span></a>Server &amp; Client for UDP Sockets</h4> <a id="server--client-for-udp-sockets" class="anchor" href="#server--client-for-udp-sockets" aria-hidden="true"><span class="octicon octicon-link"></span></a>Server &amp; Client for UDP Sockets</h4>
<p>UDP Sockets are different than Unix &amp; TCP Sockets because they must be bound to a unique port on their machine to recieve messages. For example, A TCP or Unix Socket client could just connect to a seperate TCP or Unix Socket sever. That client could then exchange, both send and recive, data on the servers port or location. UDP Sockets can not do this. They must bind to a port to recieve or send data. </p> <p>UDP Sockets are different than Unix, Windows &amp; 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. </p>
<p>This means a UDP Client and Server are the same thing because inorder to recieve data, a UDP Socket must have its own port to recieve data on, and only one process can use this port at a time. It also means that inorder to <code>emit</code> or <code>broadcast</code> data the UDP server will need to know the host and port of the Socket it intends to broadcast the data to.</p> <p>This 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 <code>emit</code> or <code>broadcast</code> data the UDP server will need to know the host and port of the Socket it intends to broadcast the data to.</p>
<p>This is the most basic example which will work for both local Unix Sockets and local or remote network TCP Sockets.</p> <p>This is the most basic example which will work for both local and remote UDP Sockets.</p>
<h5> <h5>
<a id="udp-server-1---world" class="anchor" href="#udp-server-1---world" aria-hidden="true"><span class="octicon octicon-link"></span></a>UDP Server 1 - "World"</h5> <a id="udp-server-1---world" class="anchor" href="#udp-server-1---world" aria-hidden="true"><span class="octicon octicon-link"></span></a>UDP Server 1 - "World"</h5>
@ -770,7 +781,7 @@ ipc.serveNet(
); );
ipc.server.emit( ipc.server.emit(
{ {
address : 'localhost', address : '127.0.0.1', //any hostname will work
port : ipc.config.networkPort port : ipc.config.networkPort
}, },
'message', 'message',
@ -785,6 +796,63 @@ ipc.serveNet(
ipc.server.define.listen.message='This event type listens for message strings as value of data key.'; ipc.server.define.listen.message='This event type listens for message strings as value of data key.';
ipc.server.start(); ipc.server.start();
</code></pre>
<h4>
<a id="raw-buffer-or-binary-sockets" class="anchor" href="#raw-buffer-or-binary-sockets" aria-hidden="true"><span class="octicon octicon-link"></span></a>Raw Buffer or Binary Sockets</h4>
<p>Binary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is <strong><em>slightly</em></strong> different.</p>
<p>When setting up a rawBuffer socket you must specify it as such :</p>
<pre><code>ipc.config.rawBuffer=true;
</code></pre>
<p>You can also specify its encoding type. The default is <code>utf8</code></p>
<pre><code>ipc.config.encoding='utf8';
</code></pre>
<p>emit string buffer :</p>
<pre><code>//server
ipc.server.emit(
socket,
'hello'
);
//client
ipc.of.world.emit(
'hello'
)
</code></pre>
<p>emit byte array buffer :</p>
<pre><code>//server
ipc.server.emit(
socket,
[10,20,30]
);
//client
ipc.server.emit(
[10,20,30]
);
</code></pre>
<p>emit hex array buffer :</p>
<pre><code>//server
ipc.server.emit(
socket,
[0x05,0x6d,0x5c]
);
//client
ipc.server.emit(
[0x05,0x6d,0x5c]
);
</code></pre> </code></pre>
</section> </section>
</div> </div>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,116 @@
/*
Copyright 2014 GitHub Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.pl-c /* comment */ {
color: #969896;
}
.pl-c1 /* constant, markup.raw, meta.diff.header, meta.module-reference, meta.property-name, support, support.constant, support.variable, variable.other.constant */,
.pl-s .pl-v /* string variable */ {
color: #0086b3;
}
.pl-e /* entity */,
.pl-en /* entity.name */ {
color: #795da3;
}
.pl-s .pl-s1 /* string source */,
.pl-smi /* storage.modifier.import, storage.modifier.package, storage.type.java, variable.other, variable.parameter.function */ {
color: #333;
}
.pl-ent /* entity.name.tag */ {
color: #63a35c;
}
.pl-k /* keyword, storage, storage.type */ {
color: #a71d5d;
}
.pl-pds /* punctuation.definition.string, string.regexp.character-class */,
.pl-s /* string */,
.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */,
.pl-sr /* string.regexp */,
.pl-sr .pl-cce /* string.regexp constant.character.escape */,
.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */,
.pl-sr .pl-sre /* string.regexp source.ruby.embedded */ {
color: #183691;
}
.pl-v /* variable */ {
color: #ed6a43;
}
.pl-id /* invalid.deprecated */ {
color: #b52a1d;
}
.pl-ii /* invalid.illegal */ {
background-color: #b52a1d;
color: #f8f8f8;
}
.pl-sr .pl-cce /* string.regexp constant.character.escape */ {
color: #63a35c;
font-weight: bold;
}
.pl-ml /* markup.list */ {
color: #693a17;
}
.pl-mh /* markup.heading */,
.pl-mh .pl-en /* markup.heading entity.name */,
.pl-ms /* meta.separator */ {
color: #1d3e81;
font-weight: bold;
}
.pl-mq /* markup.quote */ {
color: #008080;
}
.pl-mi /* markup.italic */ {
color: #333;
font-style: italic;
}
.pl-mb /* markup.bold */ {
color: #333;
font-weight: bold;
}
.pl-md /* markup.deleted, meta.diff.header.from-file */ {
background-color: #ffecec;
color: #bd2c00;
}
.pl-mi1 /* markup.inserted, meta.diff.header.to-file */ {
background-color: #eaffea;
color: #55a532;
}
.pl-mdr /* meta.diff.range */ {
color: #795da3;
font-weight: bold;
}
.pl-mo /* meta.output */ {
color: #1d3e81;
}

View file

@ -3,7 +3,7 @@ Slate Theme for GitHub Pages
by Jason Costello, @jsncostello by Jason Costello, @jsncostello
*******************************************************************************/ *******************************************************************************/
@import url(pygment_trac.css); @import url(github-light.css);
/******************************************************************************* /*******************************************************************************
MeyerWeb Reset MeyerWeb Reset