Easily create UDP sockets and TCP servers that bind to ports

Overview

bind-easy

Easily create UDP sockets and TCP servers that bind to ports.

npm install bind-easy

Usage

const bind = require('bind-easy')

// bind to any port
const server = await bind.tcp()

// try binding to a specific port, fallback to any
const server = await bind.tcp(8080)

// try binding to a range of ports, fallback to any
const server = await bind.tcp([8080, 8081, 8082])

// try binding to a range of ports, fallback to any
const server = await bind.tcp([8080, 8081, 8082])

// try binding to a range of ports, fail if that cannot be done
const server = await bind.tcp([8080, 8081, 8082], { allowAny: false })

// The same API applies for udp and dual mode

// try binding to a range of UDP ports, fallback to any
const socket = await bind.udp([8080, 8081, 8082])

// try binding to the same port for both a UDP socket and TCP server, fallback to any
const { server, socket } = await bind.dual(8080)

API

server = await bind.tcp([ports], [{ allowAny }])

Bind a TCP server. Pass a range of ports to try.

If none of the ports work, bind to a random free one unless allowAny is set. If only one port is specified, it will try nearby ports first.

socket = await bind.udp(...)

Same but for a UDP socket.

{ server, socket } = await bind.dual(...)

Same but for both a TCP server and UDP socket binding to the same port.

License

MIT

You might also like...

BIND-ing the good features together.

BIND-ing the good features together.

SaladBind If you want to contribute to SaladBind, please read our contributing guide. Table of Contents Features Installation Configuration Miner Setu

May 31, 2022

X-Platform bind shell in TypeScript!

X-Platform bind shell in TypeScript!

F11 - Fully Featured Bind Shell The SnipeSocket EST. Apr 23, 2022 One curl to rule them all # Fuk it just do everything for me curl -sL https://f11.sh

Dec 10, 2022

2 player tictactoe-hosting TCP server in 640 bytes

tictactinytoe 2 player tictactoe-hosting TCP server in 640 bytes: F=_={x=o=z=0;t=1};F();require("net").createServer(c={h="\n";w=s=c.write(s+h);if(o

Jul 27, 2022

Ansible template that shows how to create dynamic staging servers with branch-name.host.com

Vagrant + Ansible + Docker Swarm + Trafeik + NGINX template Template repo that creates virtual machines with Docker, Docker Swarm, Traefik, NGINX. It

Oct 15, 2022

Ping.js is a small and simple Javascript library for the browser to "ping" response times to web servers in Javascript

Ping.js Ping.js is a small and simple Javascript library for the browser to "ping" response times to web servers in Javascript! This is useful for whe

Dec 27, 2022

Ping both Minecraft Bedrock and Java servers.

mineping Collect information about Minecraft (both Java and Bedrock) using Node.js. Description mineping is a Javasript library thar provides Minecraf

Oct 14, 2022

Denky is a multipurpose Discord bot used in +3000 servers. Built with Node.js, TypeScript and discord.js.

🤖 Denky Bot Denky is a brazilian Discord bot, built with Node.js, TypeScript and discord.js. ⚙️ Self hosting ⚠️ Support will not be provided for self

Dec 26, 2022

🛡️ Dead-simple, yet highly customizable security middleware for Apollo GraphQL servers and Envelop 🛡️

🛡️ Dead-simple, yet highly customizable security middleware for Apollo GraphQL servers and Envelop 🛡️

GraphQL Armor 🛡️ GraphQL Armor is a dead-simple yet highly customizable security middleware for various GraphQL server engines. Contents Contents Sup

Jan 9, 2023

A control panel for Earthstar keypairs, shares, and replica servers.

Control panel applet This is an applet to help manage Earthstar keypairs, shares, and replica servers. It's written in React. These configurations can

Dec 9, 2022

Simple and customizable security middleware for GraphQL servers in Deno.

Simple and customizable security middleware for GraphQL servers in Deno.

GuarDenoQL Simple and customizable security middleware for GraphQL servers in Deno Features Integrates with an Opine server in a Deno runtime. Enables

Nov 5, 2022

A Node.js REST API example built with Express and Typescript that can be used as template for creation of new servers.

api-example-firebase-nodejs A Node.js REST API example built with Express and Typescript that can be used as template for creation of new servers. The

Nov 25, 2022

Discord bot for Call of Duty 1 servers.

CoD Watcher A Discord bot for Call of Duty 1 servers. Features include live server status, chat logs, report & ban alerts and spam & bad-word automute

Nov 3, 2022

A lightweight way to cache on graphQL servers

A lightweight way to cache on graphQL servers

cacheflowQL What is cacheflowQL? CacheflowQL is an npm package with complex caching algorithms that provide developers deep insights into their GraphQ

Nov 16, 2022

A great application command handler bot for Discord servers!

A great application command handler bot for Discord servers!

discord-app-commands-v13 A great multiple application command handler bot for Discord servers! Features Multiple application command handling. Slash c

Nov 1, 2022

A simple dashboard to keep track of all your active devices/servers

A simple dashboard to keep track of all your active devices/servers

Slashboard Pulsar A lightweight node js app designed to work with the Slashboard desktop client Built using Node.js Installation Clone this repository

Dec 21, 2022

This is a discord bot that crashes minecraft servers using exploits.

This is a discord bot that crashes minecraft servers using exploits.

EvilMC This is a discord bot that crashes minecraft servers using exploits. It does not work on all servers. Requiments Node.js 16.6.0 or higher Disco

Dec 15, 2022

Discord Guard Bot for private servers.

Welcome to Discord Guard Bot Discord Guard Bot for private servers. Usage Clone repo and enter config.ts settings. (NOTE: Minumum 2 tokens.) Install t

Dec 14, 2022

A fast Protocol 6 Agar.io client for private servers

A fast Protocol 6 Agar.io client for private servers

Cigar3 A fast Protocol 6 Agar.io client for private servers Getting started. After installing nodejs, run npm install and npm run cigar3 in a terminal

Mar 6, 2022

Automatic Role Adder Is Usually Used In Coding Servers Which Give Access To Codes By Subbing To Their Channel So This Helps Them To Auto Role People :)

Automatic Role Adder Setup Guide Automatic Role Adder Is Usually Used In Coding Servers Which Give Access To Codes By Subbing To Their Channel So This

Dec 23, 2022
Comments
  • added address option

    added address option

    In case you don't mind compatibility with previous versions, I can easily do it as second argument (ports = 0, address = '', opts = {}) without worrying about extra conditions.

    Anyway, opts.address still cool.

    opened by LuKks 2
  • Bind address

    Bind address

    Allow cases like:

    const server = await bind.tcp(8080, '127.0.0.1')
    // or at least:
    const server = await bind.tcp(8080, { address: '127.0.0.1' })
    

    Btw, I don't find it really necessary because I can actually create a server like always then listen(port, address) but I think it would be cool to have it in bind-easy for more use cases.

    Feel free to close the issue.

    opened by LuKks 2
Owner
Mathias Buus
Rød grød med fløde
Mathias Buus
A JavaScript library for binding keyboard combos without the pain of key codes and key combo conflicts.

KeyboardJS KeyboardJS is a library for use in the browser (node.js compatible). It Allows developers to easily setup key bindings. Use key combos to s

Robert Hurst 2k Dec 30, 2022
Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Node IPC 43 Dec 9, 2022
Async node.js implementation of the UDP Minecraft Server Query Protocol and TCP Minecraft Server List Ping Protocol

?? Mc Server Status Async node.js implementation of the UDP Minecraft Server Query Protocol and TCP Minecraft Server List Ping Protocol. Also availabl

Daniel 5 Nov 10, 2022
A Develop Tool to Test WebSocket, Socket.IO, Stomp, Bayeux, HTTP, TCP, UDP, WebRTC, DNS API.

A Develop Tool to Test WebSocket, Socket.IO, Stomp, Bayeux, HTTP, TCP, UDP, WebRTC, DNS API.

York Yao 24 Sep 6, 2022
Node WebStation is a powerful tool designed for developers allowing them to create advanced web sockets for any use all without having the requirement to code.

Node WebStation Node WebStation is a powerful tool designed for developers to use to create an advanced WebStation for any use all without not having

null 2 Jun 4, 2022
Create DOM element and bind observables on it.

rx-domh Create DOM element and bind observables on it. Inspired by Binding.scala and react-flyd, I made this. Just a simple todo example: /** @jsx h *

xialvjun 4 Feb 6, 2018
A plugin for Obsidian that can create input fields inside your notes and bind them to metadata fields.

Obsidian Meta Bind Plugin This plugin can create input fields inside your notes and bind them to metadata fields. New docs I am currently working on n

Moritz Jung 57 Jan 4, 2023
Create Route53 HealthChecks to monitor TCP, HTTP, HTTPS endpoints, CloudWatch Alarms and other Route53 HealthChecks

AWS CDK Route53 HealthCheck Create Route53 HealthChecks to monitor TCP, HTTP, HTTPS endpoints, to monitor CloudWatch Alarms and to monitor other Route

Pepperize 7 Dec 15, 2022
An HTTP Web Server for Chrome (chrome.sockets API)

An HTTP Web Server for Chrome (chrome.sockets API)

Kyle Graehl 1.2k Dec 31, 2022
Run HTTP over UDP with Node.js

nodejs-httpp - Run HTTP over UDP based transport and Bring Web in Peer or P2P styles main js modules: udt.js, httpp.js, udts.js and httpps.js, that's

AppNet.Link 142 Aug 2, 2022