updated for default system networking preference ipv4 or ipv6

This commit is contained in:
Brandon Nozaki Miller 2015-07-26 21:52:02 -07:00
parent badac96190
commit 1326a4c162
4 changed files with 14 additions and 7 deletions

3
.brackets.json Normal file
View file

@ -0,0 +1,3 @@
{
"sbruchmann.staticpreview.basepath": "/home/bmiller/git/node-ipc/"
}

View file

@ -62,7 +62,7 @@ Set these variables in the ``ipc.config`` scope to overwrite or set default valu
appspace : 'app.', appspace : 'app.',
socketRoot : '/tmp/', socketRoot : '/tmp/',
id : os.hostname(), id : os.hostname(),
networkHost : '127.0.0.1', //we use this instead of localhost as default because windows without network connection turns dns off and is unable to find localhost like other... smarter... OSes 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',
silent : false, silent : false,
@ -275,7 +275,7 @@ Used to create TCP, TLS or UDP Socket Server to which Clients can bind or other
| variable | required | definition | | variable | required | definition |
|----------|----------|------------| |----------|----------|------------|
| host | optional | If not specified this defaults to 127.0.0.1. For TCP, TLS & UDP servers this is most likely going to be 127.0.0.1 or 0.0.0.0 unless you have something like [node-http-server](https://github.com/RIAEvangelist/node-http-server) installed to run subdomains for you. | | 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 |
| port | optional | The port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified | | 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. | 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 | | callback | optional | Function to be called when the server is created |

View file

@ -1,4 +1,5 @@
var os = require('os'), var os = require('os'),
dns = require('dns'),
util = require('util'), util = require('util'),
colors = require('colors'), colors = require('colors'),
pubsub = require('event-pubsub'), pubsub = require('event-pubsub'),
@ -21,7 +22,9 @@ colors.setTheme(
var defaults={ var defaults={
appspace : 'app.', appspace : 'app.',
socketRoot : '/tmp/', socketRoot : '/tmp/',
networkHost : '127.0.0.1', networkHost : os.networkInterfaces()[
Object.keys(os.networkInterfaces())[0]
][0].address,
networkPort : 8000, networkPort : 8000,
id : os.hostname(), id : os.hostname(),
encoding : 'utf8', encoding : 'utf8',
@ -160,17 +163,18 @@ function serveNet(host,port,UDPType,callback){
if(!callback) if(!callback)
callback=function(){}; callback=function(){};
ipc.server=new Server( ipc.server=new Server(
host, host,
ipc.config, ipc.config,
log, log,
port port
); );
if(UDPType) if(UDPType)
ipc.server[UDPType]=true; ipc.server[UDPType]=true;
ipc.server.on( ipc.server.on(
'start', 'start',
callback callback

View file

@ -1,6 +1,6 @@
{ {
"name": "node-ipc", "name": "node-ipc",
"version": "1.1.13", "version": "1.2.1",
"description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.", "description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.",
"main": "node-ipc.js", "main": "node-ipc.js",
"directories": { "directories": {