cordova-plugin-portfinder
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

cordova-plugin-portfinder

This plugin defines a global portfinder object. Although the object is in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    // Get a free port, 1234 default
    portfinder.getPort(1234).then((port) => {
        console.info(port);
    }).catch((e) => {
        console.warn(e);
    });
}

Installation

cordova plugin add cordova-plugin-portfinder

Properties

  • portfinder.getPort
  • portfinder.getPortWithHost

portfinder.getPort

Get a free port. This method accept an optional default port as a parameter.

Examples

    portfinder.getPort().then((port) => {
        console.info(port);
    }).catch((e) => {
        console.warn(e);
    });

    portfinder.getPort(1234).then((port) => {
        console.info(port);
    }).catch((e) => {
        console.warn(e);
    });

portfinder.getPortWithHost

Get a free port with a specific host address. This method accept an optional default port as a parameter.

Example

    portfinder.getPortWithHost('192.168.1.50').then((port) => {
        console.info(port);
    }).catch((e) => {
        console.warn(e);
    });

    portfinder.getPortWithHost('192.168.1.50', 1234).then((port) => {
        console.info(port);
    }).catch((e) => {
        console.warn(e);
    });

Supported Platforms

  • Android
  • iOS

Package Sidebar

Install

npm i cordova-plugin-portfinder

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

16.8 kB

Total Files

11

Last publish

Collaborators