' DNS Resolution via Win32 DECLARE — gethostname, gethostbyname
#COMPILE EXE
#DIM ALL

DECLARE FUNCTION WSAStartup LIB "WS2_32.DLL" (BYVAL wVersionRequired AS LONG, BYREF lpWSAData AS LongPtr) AS LONG
DECLARE FUNCTION WSACleanup LIB "WS2_32.DLL" () AS LONG
DECLARE FUNCTION gethostname LIB "WS2_32.DLL" (BYREF name AS BYTE, BYVAL namelen AS LONG) AS LONG
DECLARE FUNCTION gethostbyname LIB "WS2_32.DLL" (BYREF name AS BYTE) AS LONG

FUNCTION PBMAIN() AS LONG
    LOCAL buf(63) AS BYTE
    LOCAL result AS LONG
    PRINT "DNS Resolution via Win32 DECLARE:"
    PRINT "gethostname -> local host name"
    PRINT "gethostbyname -> resolve host to address"
    PRINT "HOST ADDR and HOST NAME in native PB"
    FUNCTION = 0
END FUNCTION
