And reverse DNS, to get the hostname from an IP address. Anyone know why Windows takes so long to do this kind of thing? It takes a good few seconds here...
Procedure.l IntFromAddress (ip$)
ProcedureReturn inet_addr_ (@ip$)
EndProcedure
Procedure.s AddressFromInt (ip.l)
ProcedureReturn PeekS (inet_ntoa_ (ip))
EndProcedure
; Create WSA version number (damn, ugly!)...
high.b = 1: low.b = 1
wsaversion.w
PokeB (@wsaversion, high) ; Gotta poke major version number into low byte...
PokeB (@wsaversion + 1, low) ; ... and minor version number into high byte
If WSAStartup_ (wsaversion, wsa.WSAData) = #NOERROR
ip$ = "192.168.0.2" ; PC on local network
; ip$ = "212.58.226.79" ; BBC News site (shows "newslb308.telhc.bbc.co.uk" at time of writing)
ipaddr = IntFromAddress (ip$)
*host.hostent = gethostbyaddr_ (@ipaddr, 4, #AF_INET)
If *host
Debug ip$ + " = " + PeekS (*host\h_name)
Else
Debug "Error... parse results as per MSDN!"
EndIf
WSACleanup_ () ; Close Windows sockets stuff...
EndIf
Hi-Toro wrote:And reverse DNS, to get the hostname from an IP address. Anyone know why Windows takes so long to do this kind of thing? It takes a good few seconds here...
Procedure.l IntFromAddress (ip$)
ProcedureReturn inet_addr_ (@ip$)
EndProcedure
Procedure.s AddressFromInt (ip.l)
ProcedureReturn PeekS (inet_ntoa_ (ip))
EndProcedure
; Create WSA version number (damn, ugly!)...
high.b = 1: low.b = 1
wsaversion.w
PokeB (@wsaversion, high) ; Gotta poke major version number into low byte...
PokeB (@wsaversion + 1, low) ; ... and minor version number into high byte
If WSAStartup_ (wsaversion, wsa.WSAData) = #NOERROR
ip$ = "192.168.0.2" ; PC on local network
; ip$ = "212.58.226.79" ; BBC News site (shows "newslb308.telhc.bbc.co.uk" at time of writing)
ipaddr = IntFromAddress (ip$)
*host.hostent = gethostbyaddr_ (@ipaddr, 4, #AF_INET)
If *host
Debug ip$ + " = " + PeekS (*host\h_name)
Else
Debug "Error... parse results as per MSDN!"
EndIf
WSACleanup_ () ; Close Windows sockets stuff...
EndIf
almost instant here, not enough delay to even have enough time to say "hmmm"
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.