1.0.2 • Published 3 years ago

@js-util/net-socket-connect v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

net-socket-connect

Given the remote port/host, setup a low level, net.Socket. With callbacks and connect timeout!

npm install

npm install --save @js-util/net-socket-connect

Example usage

PS: This is incomplete code, you will need to modify for your actual use case.

// Load the module
const netSocketTimeout = require("@js-util/net-socket-connect);

// Create the server with the socket listening event
let remotesocket = netSocketTimeout(80, "127.0.0.1", (socket, err) => {
	
	if( err ) {
		console.error(err);
		return;
	}

	doSomethingWithSocket(socket);

}, 5000 /* connect timeout in ms */ );