Sample code for 30+ languages & platforms
Tcl

Resolve a Hostname to an IP Address

See more Socket/SSL/TLS Examples

Demonstrates Socket.DnsLookup, which resolves a hostname and returns one numeric IP address.

Background. A maxWaitMs of 0 waits indefinitely; a positive value bounds the wait. Resolved results may be served from Chilkat's process-wide DNS cache.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set socket [new_CkSocket]

#  Resolve a hostname to a numeric IP address, waiting up to 5 seconds.
set ipAddress [CkSocket_dnsLookup $socket "example.com" 5000]
if {[CkSocket_get_LastMethodSuccess $socket] == 0} then {
    puts [CkSocket_lastErrorText $socket]
    delete_CkSocket $socket
    exit
}

puts "Resolved IP address: $ipAddress"

delete_CkSocket $socket