wilton.js  v202103141
 All Namespaces Functions
Functions
net Namespace Reference

wilton/net
Networking operations. More...

Functions

Array resolveHostname (Object options, Function|Undefined callback)
 Find IP address for the specified hostname.
Undefined waitForTcpConnection (Object options, Function|Undefined callback)
 Wait for the remote TCP endpoint to become accessible.

Detailed Description

This module provide a number of networking oprerations, auxilary to the networking sockets API provided by wilton/Socket module.

Usage example:

// resolve hostname to a list of IP addresses
var ipList = net.resolveHostname({
hostname: "github.com",
timeoutMillis: 3000
});
// wait for the TCP endpoint to become available
net.waitForTcpConnection({
ipAddress: "127.0.0.1",
tcpPort: 8080,
timeoutMillis: 10000
});

Function Documentation

Array net::resolveHostname ( Object  options,
Function|Undefined  callback 
)

Finds the list of IPv4 addresses for the specified hostname. If call exits without exception, the returned list of IP addresses is always non-empty.

Parameters
optionsObject configuration object, see possible options below
callbackFunction|Undefined callback to receive result or error
Returns
Array list of IP addresses

Options

  • hostname String hostname to resolve
  • timeoutMillis Number max wait time, in milliseconds
Undefined net::waitForTcpConnection ( Object  options,
Function|Undefined  callback 
)

Tries to connect to the specified TCP endpoint. Throws Error on timeout.

Intended to be used to check the state of the started HTTP server in spawned process.

Parameters
optionsObject configuration object, see possible options below
callbackFunction|Undefined callback to receive result or error
Returns
Undefined

Options

  • ipAddress String IPv4 network address
  • tcpPort Number TCP port
  • timeoutMillis Number max wait time, in milliseconds