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.',
socketRoot : '/tmp/',
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,
encoding : 'utf8',
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 |
|----------|----------|------------|
| 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 |
| 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 |

View file

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

View file

@ -1,6 +1,6 @@
{
"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.",
"main": "node-ipc.js",
"directories": {