Sample code for 30+ languages & platforms
DataFlex

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 DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoSocket
    String sIpAddress
    String sTemp1
    Boolean bTemp1

    Get Create (RefClass(cComChilkatSocket)) To hoSocket
    If (Not(IsComObjectCreated(hoSocket))) Begin
        Send CreateComObject of hoSocket
    End

    //  Resolve a hostname to a numeric IP address, waiting up to 5 seconds.
    Get ComDnsLookup Of hoSocket "example.com" 5000 To sIpAddress
    Get ComLastMethodSuccess Of hoSocket To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoSocket To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Resolved IP address: " sIpAddress


End_Procedure