How to use the unix-dgram.createSocket function in unix-dgram

To help you get started, we’ve selected a few unix-dgram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kipraske / web-brogue / server / brogue / brogue-interface.js View on Github external
BrogueInterface.prototype.attachChildEvents = function () {

    var self = this;

    try { fs.unlinkSync(this.getChildWorkingDir() + "/" + CLIENT_SOCKET); } catch (e) { /* swallow */ }

    this.brogueClientSocket = unixdgram.createSocket('unix_dgram');
    this.brogueClientSocket.on('message', function(data, rinfo) {

        //Callback when receiving data on the socket from brogue

        self.lastActiveTime = new Date().getTime();

        var remainderLength = self.dataRemainder.length;

        //console.log("d: " + data.length);

        //fill the data buffer with the remainder from last time and the new data
        self.dataAccumulator = new Buffer(data.length + remainderLength);
        self.dataToSend = new Buffer(data.length + remainderLength);
        self.dataRemainder.copy(self.dataAccumulator);
        data.copy(self.dataAccumulator, remainderLength, 0);
github luan007 / edge-node-wrt / System / SubSys / Native / dnsmasq.ts View on Github external
//            this.relay_id, true, cb);
        //    } else {
        //        recho("#!/bin/bash\necho \"{ \\\"Action\\\":\\\"$1\\\", \\\"Lease\\\": { \\\"MAC\\\":\\\"$2\\\", \\\"Address\\\":\\\"$3\\\", \\\"Hostname\\\":\\\"$4\\\", \\\"VendorClass\\\":\\\"$DNSMASQ_VENDOR_CLASS\\\", \\\"Interface\\\":\\\"$DNSMASQ_INTERFACE\\\" }}\" | socat - UNIX-SENDTO:/tmp/dnsmasq_event_socket",
        //            _Socket_Relay_Path + ".virtual", true, cb);
        //    }
        //});


        if (Node.fs.existsSync(this.relay_path) && Node.fs.unlinkSync(this.relay_path));
        if (Node.fs.existsSync(sock) && Node.fs.unlinkSync(sock));
        var d = "#!/bin/bash\necho \"{ \\\"Action\\\":\\\"$1\\\", \\\"Lease\\\": { \\\"Mac\\\":\\\"$2\\\", \\\"Address\\\":\\\"$3\\\", \\\"Hostname\\\":\\\"$4\\\", \\\"VendorClass\\\":\\\"$DNSMASQ_VENDOR_CLASS\\\", \\\"Interface\\\":\\\"$DNSMASQ_INTERFACE\\\" }}\" | socat - UNIX-SENDTO:" + sock;
        Node.fs.writeFileSync(this.relay_path, d);
        info("Relay Generated at " + this.relay_path);
        Node.fs.chmodSync(this.relay_path, 777); //woo
        info("Relay getting +0777 - wooo");
        var client = unix.createSocket('unix_dgram', this._onrawdata); //well well
        this._socketclient = client;
        client.bind(sock);
        Node.fs.chmodSync(sock, 777); //woo
        client.on('error', (err) => {
            error("DNSMASQ ERROR");
            error(err);
        });
        info("DNSMASQ Event Hook Online");

        //jobs.push((cb) => {
        //    warn("*WORKAROUND* NON-CLOSING FD DURING VM_FUSE SESSION - line 264");
        //    cb();
        //});

        //jobs.push((cb) => {
        //    rcp(_Socket_Relay_Path + ".virtual", _Socket_Relay_Path, cb);
github luan007 / edge-node-wrt / SYS / Common / Native / dnsmasq.ts View on Github external
//            this.relay_id, true, cb);
        //    } else {
        //        recho("#!/bin/bash\necho \"{ \\\"Action\\\":\\\"$1\\\", \\\"Lease\\\": { \\\"MAC\\\":\\\"$2\\\", \\\"Address\\\":\\\"$3\\\", \\\"Hostname\\\":\\\"$4\\\", \\\"VendorClass\\\":\\\"$DNSMASQ_VENDOR_CLASS\\\", \\\"Interface\\\":\\\"$DNSMASQ_INTERFACE\\\" }}\" | socat - UNIX-SENDTO:/tmp/dnsmasq_event_socket",
        //            _Socket_Relay_Path + ".virtual", true, cb);
        //    }
        //});


        if (fs.existsSync(this.relay_path) && fs.unlinkSync(this.relay_path));
        if (fs.existsSync(sock) && fs.unlinkSync(sock));
        var d = "#!/bin/ash\necho \"{ \\\"Action\\\":\\\"$1\\\", \\\"Lease\\\": { \\\"Mac\\\":\\\"$2\\\", \\\"Address\\\":\\\"$3\\\", \\\"Hostname\\\":\\\"$4\\\", \\\"VendorClass\\\":\\\"$DNSMASQ_VENDOR_CLASS\\\", \\\"Interface\\\":\\\"$DNSMASQ_INTERFACE\\\" }}\" | socat - UNIX-SENDTO:" + sock;
        fs.writeFileSync(this.relay_path, d);
        info("Relay Generated at " + this.relay_path);
        fs.chmodSync(this.relay_path, 777); //woo
        info("Relay getting +0777 - wooo");
        var client = unix.createSocket('unix_dgram', this._onrawdata); //well well
        this._socketclient = client;
        client.bind(sock);
        fs.chmodSync(sock, 777); //woo
        client.on('error', (err) => {
            error("DNSMASQ ERROR");
            error(err);
        });
        info("DNSMASQ Event Hook Online");

        //jobs.push((cb) => {
        //    warn("*WORKAROUND* NON-CLOSING FD DURING VM_FUSE SESSION - line 264");
        //    cb();
        //});

        //jobs.push((cb) => {
        //    rcp(_Socket_Relay_Path + ".virtual", _Socket_Relay_Path, cb);
github bnf / node-systemd-daemon / lib / notify.js View on Github external
module.exports = function(state) {
	if (!process.env.NOTIFY_SOCKET) {
		return;
	}

	if (!unix) {
		return;
	}

	var message = Buffer(state + '\n');
	var client = unix.createSocket('unix_dgram');
	client.on('error', console.error);
	client.send(message, 0, message.length, process.env.NOTIFY_SOCKET);
	client.close();
}
github kipraske / web-brogue / server / brogue / brogue-interface.js View on Github external
BrogueInterface.prototype.start = function (data, mode) {

    //Support reconnect

    //Test if we can send to server socket, if so, no need to spawn a new process, just attach
    //This may happen on first connect after server restart, for example

    this.createBrogueDirectoryIfRequired();

    var sendBuf = new Buffer(5);
    sendBuf[0] = SCREEN_REFRESH;

    this.brogueSocket = unixdgram.createSocket('unix_dgram');

    var self = this;
    //Note: relies on synchronous callback
    this.brogueSocket.send(sendBuf, 0, 5, this.getChildWorkingDir() + "/" + SERVER_SOCKET, function (err) {

        if (err) {
            //If the game doesn't exist, and we are trying to play or watch a recording (not observe),
            //Create a new game
            if (mode != brogueMode.OBSERVE) {
                self.newBrogueProcess(data, mode);
            }
            else {
                throw new Error("Trying to observe game that does not exist.");
            }
        }
        //Okay to connect through socket to running process

unix-dgram

Unix datagram socket

ISC
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis

Popular unix-dgram functions