Thanks for reply
1/ somaconn
I found Somaxconn = 5 (#define) in this doc <!-- m -->
http://www.sockets.com/winsock.htm<!-- m -->
I'm not a programmer so dunno if "SOMAXCONN" string work with AHK and haven't acces to WinSock2.h ( or how do it )
2/&3/ freeaddrinfo it's strange, I check with a numget loop, it's free memory of sockaddr but not the strange pointer, but I haven't recheck ( perhaps my fault with logic error )
IPAddress = www.google.com
Port = 80 ; it's an option
; ... WSAStartUp ...
VarSetCapacity(mask, 256, 0) ; it's an option, you select ipv4 or ipv6 for return of numeric address
NumPut(2, mask, 4, "Short") ; 2 = ipv4 23 = ipv6
VarSetCapacity(Result, 256, 0)
msgbox % DllCall("Ws2_32\getaddrinfo", "Str", IPAddress, "Str", Port, "UInt", &mask, "UInt", &Result) " GetAddrInfo "
msgbox % DllCall("Ws2_32\WSAGetLastError") " Error "
;DllCall("Ws2_32\"GetAddrInfo", ... , "UInt*", Result) / ... , "UInt", &Result)
;msgbox % DllCall("Ws2_32\freeaddrinfo", "UInt *", Result)
;msgbox % DllCall("Ws2_32\freeaddrinfo", "UInt", Result)
;msgbox % DllCall("Ws2_32\freeaddrinfo", "UInt", &Result)
loop 256 ; just for check Value, they parse value of structure in other structure ( ref table at bottom )
msgbox % NumGet(NumGet(Result, 0, "UInt")+a_index-1, 0, "UChar") " AddrInfo Result " a_index-1
; 0 -> 4 = allready an numeric address
; 4 -> 2 = ipv4 , 23 = ipv6
; 16 - > len (v4=16 v6=28)
; 24 to 39> ???? canon name ? can't have a good translation of this in french
; 40 -> begin of sockaddr: 2 = ipv4 , 23 = ipv6
; 42 to 44 -> port
; 44 to 47 -> numeric address returned (if ipv4)
; 48 to 63 -> numeric address returned (if ipv6)
BUT I think to understand my error now
Edit: I have understand my mistake
Here the code who helped me, it's +24 , but +40 work but very hazardous because it works only if they are memory after addr_info (we can view this coincidence with offset value)...
Thanks again, I do Ipv6 in my script, consider this like a render thanks
IPAddress = www.google.com
;Port = 8765 ;option
VarSetCapacity(wsaData, 32, 0)
DllCall("Ws2_32\WSAStartup", "UShort", 0x0202, "UInt", &wsaData)
VarSetCapacity(mask, 32, 0)
NumPut(2, mask, 4, "Short")
DllCall("Ws2_32\getaddrinfo", "Str", IPAddress, "Str", Port, "UInt", &mask, "UInt*", Result)
log := Result "`tADRRINFO"
log .= "`n+0`tai_flags = " NumGet(Result+0)
log .= "`n+4`tai_family = " NumGet(Result+4)
log .= "`n+8`tai_socktype = " NumGet(Result+8)
log .= "`n+12`tai_protocol = " NumGet(Result+12)
log .= "`n+16`tai_addrlen = " NumGet(Result+16)
log .= "`n+24`tai_addr = " NumGet(Result+24)
log .= "`n`n"NumGet(Result+24) "`tSOCKADDR (IPV4)"
log .= "`n+0`tsin_family = " NumGet(NumGet(Result+24, 0, "UInt"), 0, "Short")
log .= "`n+2`tsin_port = " DllCall("Ws2_32\htons", "UShort", NumGet(NumGet(Result+24, 0, "UInt"), 2, "UShort") )
log .= "`n+4`tsin_address = " NumGet(NumGet(Result+24, 0, "UInt"), 4, "UChar")
loop 3
log .= "." NumGet(NumGet(Result+24, 0, "UInt"), 4+a_index, "UChar")
DllCall("Ws2_32\freeaddrinfo", "UInt", Result)
msgbox % log
VarSetCapacity(mask, 32, 0)
NumPut(23, mask, 4, "Short")
DllCall("Ws2_32\getaddrinfo", "Str", IPAddress, "Str", Port, "UInt", &mask, "UInt*", Result)
log := Result "`tADRRINFO"
log .= "`n+0`tai_flags = " NumGet(Result+0)
log .= "`n+4`tai_family = " NumGet(Result+4)
log .= "`n+8`tai_socktype = " NumGet(Result+8)
log .= "`n+12`tai_protocol = " NumGet(Result+12)
log .= "`n+16`tai_addrlen = " NumGet(Result+16)
log .= "`n+24`tai_addr = " NumGet(Result+24)
log .= "`n`n"NumGet(Result+24) "`tSOCKADDR (IPV6)"
log .= "`n+0`tsin_family = " NumGet(NumGet(Result+24), 0, "Short")
log .= "`n+2`tsin_port = " DllCall("Ws2_32\htons", "UShort", NumGet(NumGet(Result+24), 2, "UShort"))
SetFormat, IntegerFast, Hex
IPV6 := DllCall("Ws2_32\htons", "UShort", NumGet(NumGet(Result+24), 8, "UShort"))
loop 7
IPV6 .= ":" DllCall("Ws2_32\htons", "UShort", NumGet(NumGet(Result+24), 8+a_index*2, "UShort"))
SetFormat, IntegerFast, Dec
StringReplace, IPV6, IPV6, 0x, , All
log .= "`n+8`tsin_address = " IPV6
DllCall("Ws2_32\freeaddrinfo", "UInt", Result)
msgbox % log
DllCall("Ws2_32\WSACleanup")
return
;IPAddress = 0:0:0:0:0:0:0:1
;IPAddress = 127.0.0.1
;Port = 8765
;StringReplace, IPAddress, IPAddress, :, :, UseErrorLevel
;IPver := ( errorlevel = 7 ) ? 23 : 2
;VarSetCapacity(sockaddr, 128, 0)
; NumPut(IPver, sockaddr, 0, "Short")
; NumPut(DllCall("Ws2_32\htons", "UShort", Port), sockaddr, 2, "UShort")
;if IPver = 2
; NumPut(DllCall("Ws2_32\inet_addr", "Str", IPAddress), sockaddr, 4)
;if IPver = 23
; Loop, Parse, IPAddress, :
; NumPut(DllCall("Ws2_32\htons", "UShort", "0x" . a_loopfield ), sockaddr, (a_index*2)-2+8, "UShort")