Socket
Book a DemoInstallSign in
Socket

lcnet

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lcnet

Network handler for Javascript and NodeJS **Install** ``` npm i --save lcnet ```

0.0.775
latest
npmnpm
Version published
Maintainers
1
Created
Source

lcnet

Network handler for Javascript and NodeJS Install

npm i --save lcnet

How to use

  • With SocketIO
const LCSocketIO = require("lcnet").SocketIO;
const  HOST_IP  =  "127.0.0.1";
const  PORT  =  8000;
let io = new LCSocketIO();
// start the connection and start listening to some events
io.connect(HOST_IP, PORT);
io.addListener("connect", () =>  console.log("conncted!"));
io.addListener("disconnect", () =>  console.log("disconnected!"));
io.addListener("message", (data) => {
   console.log("receive >", data);
}
// send an object with the specific type
io.send("message", {type:"json object"});
// disconnect from socket
io.close();
  • With UDP
const {UDP} = require("lcnet");
 const  RECEIVE_PORT  =  3000;
const  SEND_PORT  =  3001;
 let  broadcastIP  =  UDP.getBroadcastIP();
 UDP.addListener(RECEIVE_PORT, function(data, remote) {
	console.log(`${remote.address}:${remote.port} says >`, data);
});
 UDP.send("string message", broadcastIP, SEND_PORT);

FAQs

Package last updated on 12 Aug 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.