diff --git a/index.html b/index.html index 5266d8f..d35e7bc 100644 --- a/index.html +++ b/index.html @@ -34,45 +34,416 @@
a nodejs module for local and remote Inter Process Communication
+a nodejs module for local and remote Inter Process Communication for Linux, Mac and Windows.
-npm install node-ipc
+ -this is a new project so more documentation will come
+Package details websites :
-Type | +Stability | Definition | |
---|---|---|---|
Unix Socket | -Gives lightning fast communication and avoids the network card to reduce overhead and latency. Local Unix Socket examples + | Stable | +Gives Linux and Mac lightning fast communication and avoids the network card to reduce overhead and latency. Local Unix Socket examples |
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 do not. Local or remote network TCP Socket examples | |
TLS Socket | +Alpha | coming soon... | |
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 Implementation because UDP sockets go through the network card while Unix Sockets do not. Local or remote network UDP Socket examples |
OS | +Supported Sockets | +
---|---|
Linux | +Unix, TCP, TLS, UDP | +
Mac | +Unix, TCP, TLS, UDP | +
Win | +TCP, TLS, UDP | +
Windows 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.
-ipc.config
These methods are available in the IPC Scope.
+ +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 concation from happening if the ipc is set to silent. That way if you leave your logging in place it should not effect performance.
the log also supports colors implementation. All of the available styles are supported and the theme styles are as follows :
+ +{
+ 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.connectTo(id,path,callback);
Used for connecting as a client to local Unix 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.
+ +variable | +required | +definition | +
---|---|---|
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. | +
path | +optional | +is the path of the Unix Domain Socket File, if not set this will be defaylted to ipc.config.socketRoot +ipc.config.appspace +id
+ |
+
callback | +optional | +this is the function to execute when the socket has been created. | +
examples arguments can be ommitted solong as they are still in order.
+ +ipc.connectTo('world');
+
+
+or using just an id and a callback
+ +ipc.connectTo(
+ 'world',
+ function(){
+ ipc.of.world.on(
+ 'hello',
+ function(data){
+ ipc.log(data.debug);
+ //if data was a string, it would have the color set to the debug style applied to it
+ }
+ )
+ }
+);
+
+
+or explicitly setting the path
+ +ipc.connectTo(
+ 'world',
+ 'myapp.world'
+);
+
+
+or explicitly setting the path with callback
+ +ipc.connectTo(
+ 'world',
+ 'myapp.world',
+ function(){
+ ...
+ }
+);
+
+
+ipc.connectToNet(id,host,port,callback)
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 connectTo
instead as it is much faster since it avoids the network card alltogether.
variable | +required | +definition | +
---|---|---|
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 refrence to the socket. |
+
host | +optional | +is the host on which the TCP or TLS socket resides. This will default to ipc.config.networkHost if not specified. |
+
port | +optional | +the port on which the TCP or TLS socket resides. | +
callback | +optional | +this is the function to execute when the socket has been created. | +
examples arguments can be ommitted solong as they are still in order.
+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.
ipc.connectToNet('world');
+
+
+or using just an id and a callback
+ +ipc.connectToNet(
+ 'world',
+ function(){
+ ...
+ }
+);
+
+
+or explicitly setting the host and path
+ +ipc.connectToNet(
+ 'world',
+ 'myapp.com',serve(path,callback)
+ 3435
+);
+
+
+or only explicitly setting port and callback
+ +ipc.connectToNet(
+ 'world',
+ 3435,
+ function(){
+ ...
+ }
+);
+
+
+ipc.serve(path,callback);
Used to create local Unix Socket Server to which Clients can bind. The server can emit
events to specific Client Sockets, or broadcast
events to all known Client Sockets.
variable | +required | +definition | +
---|---|---|
path | +optional | +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; | +
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(){});
+ |
+
examples arguments can be ommitted solong as they are still in order.
+ +ipc.serve();
+
+
+or specifying callback
+ +ipc.serve(
+ function(){...}
+);
+
+
+or specify path
+ +ipc.serve(
+ '/tmp/myapp.myservice'
+);
+
+
+or specifying everything
+ +ipc.serve(
+ '/tmp/myapp.myservice',
+ function(){...}
+);
+
+
+serveNet(host,port,UDPType,callback)
Used 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.
variable | +required | +definition | +
---|---|---|
host | +optional | +If not specified this defaults to localhost. For TCP, TLS & UDP servers this is most likely going to be localhost or 0.0.0.0 unless you have something like node-http-server installed to run subdomains for you. | +
port | +optional | +The port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified | +
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. | +
callback | +optional | +Function to be called when the server is created | +
examples arguments can be ommitted solong as they are still in order.
+ +default tcp server
+ +ipc.serveNet();
+
+
+default udp server
+ +ipc.serveNet('udp4');
+
+
+or specifying TCP server with callback
+ +ipc.serveNet(
+ function(){...}
+);
+
+
+or specifying UDP server with callback
+ +ipc.serveNet(
+ 'udp4',
+ function(){...}
+);
+
+
+or specify port
+ +ipc.serveNet(
+ 3435
+);
+
+
+or specifying everything TCP
+ +ipc.serveNet(
+ 'MyMostAwesomeApp.com',
+ 3435,
+ function(){...}
+);
+
+
+or specifying everything UDP
+ +ipc.serveNet(
+ 'MyMostAwesomeApp.com',
+ 3435,
+ 'udp4',
+ function(){...}
+);
+
+
+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
.
example
+ +ipc.connectTo(
+ 'world',
+ function(){
+
+ ipc.of.world.on(
+ 'message',
+ function(data){...}
+ );
+
+ }
+);
+
+
+ipc.config
Set these variables in the ipc.config
scope to overwrite or set default values.
These methods are available in the IPC Scope.
- -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 concation from happening if the ipc is set to silent. That way if you leave your logging in place it should not effect performance.
the log also supports colors implementation. All of the available styles are supported and the theme styles are as follows :
- -{
- 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.connectTo(id,path,callback);
Used for connecting as a client to local Unix 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.
- -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.path
optional is the path of the Unix Domain Socket File, if not set this will be defaylted to ipc.config.socketRoot
+ipc.config.appspace
+id
callback
optional this is the function to execute when the socket has been created.examples
- -ipc.connectTo('world');
-
-
-or using just an id and a callback
- -ipc.connectTo(
- 'world',
- function(){
- ipc.of.world.on(
- 'hello',
- function(data){
- ipc.log(data.debug);
- //if data was a string, it would have the color set to the debug style applied to it
- }
- )
- }
-);
-
-
-or explicitly setting the path
- -ipc.connectTo(
- 'world',
- 'myapp.world'
-);
-
-
-or explicitly setting the path with callback
- -ipc.connectTo(
- 'world',
- 'myapp.world',
- function(){
- ...
- }
-);
-
-
-ipc.connectToNet(id,host,port,callback)
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 connectTo
instead as it is much faster since it avoids the network card alltogether.
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 refrence to the socket.host
optional is the host on which the TCP or TLS socket resides. This will default to ipc.config.networkHost
if not specified.port
optional
-callback
optional this is the function to execute when the socket has been created.examples arguments can be ommitted solong as they are still in order.
-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.
ipc.connectToNet('world');
-
-
-or using just an id and a callback
- -ipc.connectToNet(
- 'world',
- function(){
- ...
- }
-);
-
-
-or explicitly setting the host and path
- -ipc.connectToNet(
- 'world',
- 'myapp.com',serve(path,callback)
- 3435
-);
-
-
-or only explicitly setting port and callback
- -ipc.connectToNet(
- 'world',
- 3435,
- function(){
- ...
- }
-);
-
-
-ipc.serve(path,callback);
Used to create local Unix Socket Server to which Clients can bind. The server can emit
events to specific Client Sockets, or broadcast
events to all known Client Sockets.
path
optional 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;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 as follows :
ipc.server.on( - 'start', - callback -);
-examples
- -ipc.serve();
-
-
-or specifying callback
- -ipc.serve(
- function(){...}
-);
-
-
-or specify path
- -ipc.serve(
- '/tmp/myapp.myservice'
-);
-
-
-or specifying everything
- -ipc.serve(
- '/tmp/myapp.myservice',
- function(){...}
-);
-
-
-coming soon ... -For TCP, TLS & UDP servers this is most likely going to be local host or 0.0.0.0 unless you have something like node-http-server installed to run subdomains for you.
- -