raw 128bit IPv6 address from GetClientIP()
Posted: Wed Jun 08, 2016 3:06 am
hello! I would like to read/save the raw 128-bit IPv6 address, so rather than converting it to a string with IPString() and back to raw Im assuming we can just read from the memory of the return value of GetClientIP() ? before we FreeIP() it
I modified the Echo client/server example that comes with PB and its (IPv6) working fine when I use "::1" localhost, but I can't get it to connect to any Internet sites for some reason - im guessing this is a problem with my system and not a bug, but can others please test?
Also if you could copy-and-paste the ShowMemoryViewer result along with an nslookup of whatever address it connected to that'd be great thankyou very much! hopefully from the memory dump the IP address location and byte order etc will be obvious
(i cant work it out from the ::1 localhost as its almost all nulls)
I modified the Echo client/server example that comes with PB and its (IPv6) working fine when I use "::1" localhost, but I can't get it to connect to any Internet sites for some reason - im guessing this is a problem with my system and not a bug, but can others please test?
Also if you could copy-and-paste the ShowMemoryViewer result along with an nslookup of whatever address it connected to that'd be great thankyou very much! hopefully from the memory dump the IP address location and byte order etc will be obvious

Code: Select all
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0): End
EndIf
Port = 80
addr.s = "www.ipv6ready.org" ; "www.google.com" "ipv6.google.com" "2a00:1450:4001:815::200e"
ConnectionID = OpenNetworkConnection(addr, Port, #PB_Network_TCP | #PB_Network_IPv6)
If ConnectionID
MessageRequester("PureBasic - Client", "Client connected to server...", 0)
IP = GetClientIP(ConnectionID)
ShowMemoryViewer(@IP,24) ;16 bytes IPv6 + 8 in case theres a ptr
MessageRequester("IP","Showing IP memory (but am not sure if the first field is a ptr to the data)")
CloseNetworkConnection(ConnectionID)
FreeIP(IP) ;required when GetClientIP is ipv6
Else
MessageRequester("PureBasic - Client", "Can't find the server (Is it launched ?).", 0)
EndIf