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

udp2ws

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

udp2ws

Relay UDP packets to WebSocket server

  • 2.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
48
decreased by-40%
Maintainers
1
Weekly downloads
 
Created
Source

udp2ws

NPM version Build Status Coverage Status

Relay UDP packets to WebSocket server

Install

$ npm install --save udp2ws ws

Usage

import { Relay } from 'udp2ws';

const relay = new Relay({ port: 1234 });

relay.listen(3000, () => {
  console.log('relay server listening on port 3000');
});

API

new Relay(options)

Create a new relay instance.

  • options: Set of configurable options to set on the relay. Can have the following fields:
    • type {string} Either 'udp4' or 'udp6'. Default:udp4
    • port {number} Destination port.
    • address {string} Destination host name or IP address.
    • exclusive {boolean} Boolean value true or false. Default:false
    • multicastAddress {string} The IP multicast group address.
    • multicastInterface {string} The local IP address associated with a network interface.
    • wssOptions {Object} Set of configurable options to set on the WebSocket server. Please see ws documentation for details.
    • interceptor {Function} Define the function to intercept incoming UDP packets.
Example
const relay = new Relay({
  port: '1234',
  multicastAddress: '224.0.0.114',
  interceptor: (msg, rInfo) => {
    // messages with longer length will not be relayed
    if (msg.length <= 120) return msg;
  },
});

relay.listen(port[, callback])

Starts the relay (WebSocket) server listening for connections.

  • port {number} The port where to bind the server.
  • callback {Function} Called when the server is listening for connections.

relay.close([callback])

Stops the relay (WebSocket) server from accepting new connections.

relay.socket

Accesses the dgram.Socket instance, which is available when the relay server is started.

relay.wss

Accesses the ws.WebSocketServer instance, which is available when the relay server is started.

License

MIT

Keywords

FAQs

Package last updated on 28 Sep 2023

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