Sample code for 30+ languages & platforms
PureBasic

DNS Lookup

Do a DNS lookup to resolve a hostname to an IP address.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkSocket.pb"

Procedure ChilkatExample()

    ; This example requires the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    socket.i = CkSocket::ckCreate()
    If socket.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    maxWaitMs.i = 10000
    ipAddr.s = CkSocket::ckDnsLookup(socket,"www.chilkatsoft.com",maxWaitMs)
    If CkSocket::ckLastMethodSuccess(socket) <> 1
        Debug CkSocket::ckLastErrorText(socket)
        CkSocket::ckDispose(socket)
        ProcedureReturn
    EndIf

    Debug "IP Address: " + ipAddr


    CkSocket::ckDispose(socket)


    ProcedureReturn
EndProcedure