Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unix-dgram

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unix-dgram

Unix datagram socket

  • 2.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-27.26%
Maintainers
3
Weekly downloads
 
Created

What is unix-dgram?

The unix-dgram npm package provides a way to create and manage Unix domain datagram sockets in Node.js. This allows for inter-process communication (IPC) on the same host using the Unix domain socket protocol.

What are unix-dgram's main functionalities?

Creating a Unix Datagram Socket

This feature allows you to create a Unix datagram socket and bind it to a specific path. This is useful for setting up a communication endpoint for IPC.

const dgram = require('unix-dgram');
const socket = dgram.createSocket('unix_dgram');
socket.bind('/tmp/socket');
console.log('Socket bound to /tmp/socket');

Sending Messages

This feature allows you to send messages through the Unix datagram socket. The code sample demonstrates sending a simple 'Hello, World!' message to a specified socket path.

const dgram = require('unix-dgram');
const socket = dgram.createSocket('unix_dgram');
socket.send(Buffer.from('Hello, World!'), 0, 12, '/tmp/socket', (err) => {
  if (err) console.error(err);
  else console.log('Message sent');
});

Receiving Messages

This feature allows you to receive messages sent to the Unix datagram socket. The code sample shows how to set up an event listener for incoming messages and log them to the console.

const dgram = require('unix-dgram');
const socket = dgram.createSocket('unix_dgram');
socket.on('message', (msg, rinfo) => {
  console.log('Received message:', msg.toString());
});
socket.bind('/tmp/socket');

Other packages similar to unix-dgram

FAQs

Package last updated on 17 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc