JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q51052F
  • License MIT

A simpler UDP client/server API for Node

Package Exports

  • node-udp
  • node-udp/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-udp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-udp

A simpler UDP client/server API for Node

  • Zero dependencies
  • Simple API

Install

nmp i node-udp

Usage

Server Example

const Server = require('node-udp').Server

const server = new Server({port: 30210, type: 'udp4'})

server.on('listen', data => {
  console.log('UDP Server Listening', data)
})

server.on('connect', ()=> {
  console.log('Connected')
})

// Simple terminal chat app
server.on('data', data => {
  console.log(data.toString())
})
process.stdin.on('data', data => {
  server.send(data)
})

// Close the connection
server.close()

Client Example

const Client = require('node-udp').Client

let client = new Client({server: 'localhost', port: 30210, type: 'udp4'})

client.on('listen', data => {
  console.log('UDP Client Listening', data)
})

client.on('connect', ()=> {
  console.log('Connected')
})

// Simple chat app
client.on('data', data => {
  console.log(data.toString())
})
process.stdin.on('data', data => {
  client.send(data)
})

// Close the connection
client.close()