▼ |  | Net: Networking Libraries

1 | HTTP Client
2 | URLs and HTTP
3 | URI Codec: Encoding and Decoding URIs
4 | FTP: Client
5 | Send URL: Opening a Web Browser
6 | SMTP: Sending E-Mail
7 | sendmail: Sending E-Mail
8 | Headers: Parsing and Constructing
9 | Header Field Encoding
10 | IMAP: Reading Mail
11 | POP3: Reading Mail
12 | MIME: Decoding Internet Data
13 | Base 64: Encoding and Decoding
14 | Quoted-Printable: Encoding and Decoding
15 | DNS: Domain Name Service Queries
16 | NNTP: Newsgroup Protocol
17 | TCP: Unit and Signature
18 | TCP Redirect: tcp^ via Channels
19 | SSL Unit: tcp^ via SSL
20 | CGI Scripts
21 | Cookie: Legacy HTTP Client Storage
22 | Git Repository Checkout
| Bibliography
| Index

► | 15 | DNS: Domain Name Service Queries

15.1 | Functions
15.2 | DNS Unit
15.3 | DNS Signature

On this page:

15.1`` Functions
dns-get-address
dns-get-srv
srv-rr
dns-get-name
dns-get-mail-exchanger
dns-find-nameserver
15.2`` DNS Unit
dns@
15.3`` DNS Signature
dns^

top ← prev up next →

### 15`` DNS: Domain Name Service Queries

(require net/dns) | package: net-lib

The net/dns library provides utilities for looking up hostnames.
Thanks to Eduardo Cavazos and Jason Crowe for repairs and improvements.

#### 15.1`` Functions

> > procedure
> > (dns-get-address |  | nameserver |  |  |  |
> > |  | address |  |  |  |
> > | [ | #:ipv6? ipv6?]) |  | → |  | string?
> nameserver : string?
> address : string?
> ipv6? : any/c = #f

Consults the specified nameserver (normally a numerical address like "128.42.1.30") to obtain a numerical address for the given Internet address.

The query record sent to the DNS server includes the "recursive" bit, but dns-get-address also implements a recursive search itself in case the server does not provide this optional feature.

If ipv6? is a true value, then the numerical address that is returned will be an IPv6 address. If no AAAA record exists, an error will be raised.

> procedure (dns-get-srv nameserver name service [proto]) → (listof srv-rr?)
> nameserver : string?
> name : string?
> service : string?
> proto : string? = "tcp"
> > struct
> > (struct |  | srv-rr (priority weight port target)
> #:prefab)
> priority : (integer-in 0 65535)
> weight : (integer-in 0 65535)
> port : (integer-in 0 65535)
> target : string?

> > > An SRV record is a particular kind of DNS resource record that maps an abstract service name onto a hostname and port combination. For more information, see the Wikipedia page on SRV records.

Consults the specified nameserver (normally a numerical address like "128.42.1.30") to retrieve the SRV records corresponding to the given name, service, and protocol. Returns a list of srv-rr structs if any corresponding SRV records are found; otherwise, returns '().

If service is "X", proto is "Y", and name is "example.com", then this will retrieve any SRV records at the domain name _X._Y.example.com.

The query record sent to the DNS server includes the "recursive" bit, but dns-get-srv also implements a recursive search itself in case the server does not provide this optional feature.

Examples:

> > (dns-get-srv (dns-find-nameserver) "racket-lang.org" "xmpp-client")
> '(#s(srv-rr 0 0 5222 "xmpp.racket-lang.org"))
> > (dns-get-srv (dns-find-nameserver) "racket-lang.org" "nonexistent-protocol")
> '()
> > (dns-get-srv (dns-find-nameserver) "racket-lang.org" "xmpp-client" "tcp")
> '(#s(srv-rr 0 0 5222 "xmpp.racket-lang.org"))
> > (dns-get-srv (dns-find-nameserver) "racket-lang.org" "xmpp-client" "udp")
> '()

Added in version 6.4.0.8 of package net-lib.

> procedure (dns-get-name nameserver address) → string?
> nameserver : string?
> address : string?

Consults the specified nameserver (normally a numerical address like "128.42.1.30") to obtain a name for the given numerical address.

> procedure (dns-get-mail-exchanger nameserver address) → string?
> nameserver : string?
> address : string?

Consults the specified nameserver to obtain the address for a mail exchanger the given mail host address. For example, the mail exchanger for "ollie.cs.rice.edu" might be "cs.rice.edu".

> procedure (dns-find-nameserver) → (or/c string? false/c)

Attempts to find the address of a nameserver on the present system. On Unix and Mac OS, this procedure parses "/etc/resolv.conf" to extract the first nameserver address. On Windows, it runs nslookup.exe.

#### 15.2`` DNS Unit

> > > dns@ and dns^ are deprecated. They exist for backward-compatibility and will likely be removed in the future. New code should use the net/dns module.

(require net/dns-unit) | package: compatibility-lib

> value dns@ : unit?

Imports nothing, exports dns^.

#### 15.3`` DNS Signature

(require net/dns-sig) | package: compatibility-lib

> signature dns^ : signature

Includes dns-get-address, dns-get-name, dns-get-mail-exchanger and dns-find-nameserver.

top ← prev up next →