Domain name resolver.
Resolves a domain that best matches the given options.
Resolves a domain that best matches the given options.
Resolves a domain for the TCP protocol with STREAM type, and yields each possible Addrinfo.
Resolves a domain for the UDP protocol with DGRAM type, and yields each possible Addrinfo.
Returns an IPAddress matching this addrinfo.
Struct
Value
Object
Object
Resolves a domain that best matches the given options.
mail or http services for example.Family::UNSPEC
Type::STREAM) and must be specified.Protocol::TCP) and should be specified.Example:
require "socket"
addrinfos = Socket::Addrinfo.resolve("example.org", "http", type: Socket::Type::STREAM, protocol: Socket::Protocol::TCP) Resolves a domain that best matches the given options.
Yields each possible Addrinfo resolution since a domain may resolve to many IP. Implementations are supposed to try all the addresses until the socket is connected (or bound) or there are no addresses to try anymore.
Raising is an expensive operation, so instead of raising on a connect or bind error, just to rescue it immediately after, the block is expected to return the error instead, which will be raised once there are no more addresses to try.
The iteration will be stopped once the block returns something that isn't an Exception (e.g. a Socket or nil).
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Socket/Addrinfo.html