Skip to content

Commit 3d30c98

Browse files
nwfmarcelstoer
authored andcommitted
Clarify DNS callbacks (#2860)
1 parent 73e6651 commit 3d30c98

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/modules/net.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ Provides DNS resolution for a hostname.
236236
- `domain` domain name
237237
- `function(net.socket, ip)` callback function. The first parameter is the socket, the second parameter is the IP address as a string.
238238

239+
If a callback `c` is provided, it is equivalent to having called `:on("dns",
240+
c)` on this socket; this callback will, hereafter, receive any pending
241+
resolution results recieved for this socket!
242+
239243
#### Returns
240244
`nil`
241245

@@ -580,6 +584,11 @@ Resolve a hostname to an IP address. Doesn't require a socket like [`net.socket.
580584
- `host` hostname to resolve
581585
- `function(sk, ip)` callback called when the name was resolved. `sk` is always `nil`
582586

587+
There is at most one callback for all `net.dns.resolve()` requests at any time;
588+
all resolution results are sent to the most recent callback specified at time
589+
of receipt! If multiple DNS callbacks are needed, associate them with separate
590+
sockets using [`net.socket:dns()`](#netsocketdns).
591+
583592
#### Returns
584593
`nil`
585594

0 commit comments

Comments
 (0)