Does what it says on the tin - looks up the IP address for the specified web address.
The functions:
` Loads the Winsock DLL
function WSAStartup()
load dll "Ws2_32.dll", 1
ptr = make memory(400)
result = call dll(1, "WSAStartup", 2, ptr)
delete memory ptr
endfunction result
` Unloads the Winsock DLL
function WSACleanup()
call dll 1, "WSACleanup"
delete dll 1
endfunction
` Looks up the IP address for the specified web address
function GetHostByAddr(host as string)
hostent as dword
ptr as dword
ip as dword
hostent = call dll(1, "gethostbyname", host)
if hostent = 0 then exitfunction ""
ptr = hostent + 12
ptr = *ptr
ptr = *ptr
ip = *ptr
result$ = str$(ip && 0xFF) + "." + str$((ip && 0xFF00) >> 8) + "." + str$((ip && 0xFF0000) >> 16) + "." + str$((ip && 0xFF000000) >> 24)
endfunction result$
Example:
` Start Winsock
result = WSAStartup()
if result <> 0
print "WSAStartup failed: "+str$(result)+"."
wait key
end
endif
` Get IP address
result$ = GetHostByAddr("www.thegamecreators.com")
if result$ = ""
print "GetHostByAddr failed."
wait key
end
endif
` Output IP address
print "IP Address: "+result$+"."
` Unload Winsock
WSACleanup()
wait key
end