From 3d30c985cb3b7f21d31f5fa1568b5c8272aa9140 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sat, 27 Jul 2019 13:18:34 +0100 Subject: [PATCH] Clarify DNS callbacks (#2860) --- docs/modules/net.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/modules/net.md b/docs/modules/net.md index 1667b859..dd1c0ee4 100644 --- a/docs/modules/net.md +++ b/docs/modules/net.md @@ -236,6 +236,10 @@ Provides DNS resolution for a hostname. - `domain` domain name - `function(net.socket, ip)` callback function. The first parameter is the socket, the second parameter is the IP address as a string. +If a callback `c` is provided, it is equivalent to having called `:on("dns", +c)` on this socket; this callback will, hereafter, receive any pending +resolution results recieved for this socket! + #### Returns `nil` @@ -580,6 +584,11 @@ Resolve a hostname to an IP address. Doesn't require a socket like [`net.socket. - `host` hostname to resolve - `function(sk, ip)` callback called when the name was resolved. `sk` is always `nil` +There is at most one callback for all `net.dns.resolve()` requests at any time; +all resolution results are sent to the most recent callback specified at time +of receipt! If multiple DNS callbacks are needed, associate them with separate +sockets using [`net.socket:dns()`](#netsocketdns). + #### Returns `nil`