New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

udplus

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

udplus

This Package offers a simple and easy to set up wrapper around Nodes internal "dgram" Module. It offers server and client side Functions. The API is inspired by the "Socket.io" Package.

1.2.1
latest
Source
npm
Version published
Weekly downloads
5
-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

udplus

⚠️ WORK IN PROGRESS ⚠️

This Package offers a simple and easy to set up wrapper around Nodes internal "dgram" Module. It offers server and client side Functions. The API is inspired by the "Socket.io" Package.

Creating a Server

const  udplus = require("udplus")
const  server = udplus.createServer(port)

server.listen(3000, info  => {
	console.log("listening on: " + info);
})

client.on("connection", info  => {
	console.log(info);
})

Connecting Client to local Server

const  udplus = require("udplus")
const  client = udplus.createClient()

client.connect("localhost", 3000, info  => {
    console.log("connected!", info);
})

Sending and Recieving data on Server

//emits for each connected client
server.on("connection", client  => {
	console.log("client connected: ", client.address);
	
	//Recieve data from THIS client
	client.on("custom-event", data  => {
		console.log(data);
	})
	
	//send data to THIS client
	client.emit("custom-event", data)
})

Sending and Recieving data on Client

//send from client to server
client.emit("custom-event", "Hello World")

//recieve from server
client.on("test", data  => {
	console.log(data);
})

Keywords

back-end

FAQs

Package last updated on 11 Apr 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