Example #1
0
File: net.js Project: saghul/sjs
function Socket(domain, type, options) {
    options = Object.assign({}, options);

    if (options.fd !== undefined && options.fd > -1) {
        this._fd = options.fd;
    } else {
        this._fd = _socket.socket(domain, type);
    }

    this._domain = domain;
    this._type = type;

    this._nonblock = !!options.nonBlocking;
    if (this._nonblock) {
        try {
            os.nonblock(this._fd, this._nonblock);
        } catch (e) {
            this.close();
            throw e;
        }
    }

    // set finalizer
    outil.finalizer(this, socketDealloc);

    Object.defineProperty(this, 'fd', {
        get: function() {
            return this._fd;
        }
    });
}
Example #2
0
		updateCfg: function(cfg){
			var ns = cfg.namespace,_cfg = get('config:'+ns);
			if(!ns) return;
			if(_cfg){
				var started = _cfg.__started;
				delete _cfg.__started;
				_cfg.namespace = ns;
				if(utils.object.equals(_cfg,cfg)){
					return;
				}
				cfg.__started = started;
			}
			config(cfg);
			AutoSave.reloadCfg();
		},