npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dgram-server

v0.1.0

Published

Stream-based UDP server.

Downloads

9

Readme

dgram-server

Build Status npm node license downloads Coverage Status code style

Stream-based UDP server.

Doesn't properly work with cluster.

Usage

const dgramsrv = require('dgram-server')

const server = dgramsrv.createServer()

server.on('socket', (socket) => {
  socket.on('data', (data) => {
    console.log('got %s bytes from %s:%s', data.length, socket.remoteAddress, socket.remotePort)

    socket.write('hello, world!', () => {
      socket.close()
    })
  })
})

server.listen(() => {
  console.log('udp server started on 0.0.0.0:%s', server.address().port)
})

API

  • createServer([options: Object]): Server

Creates a new UDP server. Also accept all options for dgram.createSocket(). If options.socket is provided, these options will be ignored.

  • option.socket: dgram.Socket

An optional internal dgram socket used as transport layer.

  • class Server

This class is used to create a UDP server. Server is an EventEmitter with the following events:

  • Event: 'socket'
    • socket: unicast.Socket

Emitted when a new association is made. socket is an instance of unicast.Socket.

  • Event: 'listening'

Emitted when the server has been bound after calling server.listen()

  • server.listen([port: number[, host: string]][, callback: function])
  • server.listen()

Start a server listening for associations. When the server starts listening, the 'listening' event will be emitted. The last parameter callback will be added as a listener for the 'listening' event.

  • server.close()

Close the underlying socket and stop listening for data on it.

  • server.address(): Object

Returns the bound address, the address family name, and port of the server as reported by the operating system. Useful to find which port was assigned when getting an OS-assigned address. Returns an object with port, family, and address properties: { port: 12346, family: 'IPv4', address: '127.0.0.1' }.

Don't call server.address() until the 'listening' event has been emitted.

  • server.connections: number

The number of concurrent associations on the server.

Related

  • unicast - Unicast implementation of UDP Datagram sockets.

License

MIT, 20!8 (c) Dmitriy Tsvettsikh