{$endif}\r
end;\r
\r
- {$ifdef mswindows}\r
- TInetSockAddr = packed Record\r
- family:Word;\r
- port :Word;\r
- addr :uint32;\r
- pad :array [1..8] of byte;\r
- end;\r
- {$ifdef ipv6}\r
-\r
- TInetSockAddr6 = packed record\r
- sin6_family: word;\r
- sin6_port: word;\r
- sin6_flowinfo: uint32;\r
- sin6_addr: tin6_addr;\r
- sin6_scope_id: uint32;\r
- end;\r
+ {zipplet 20170204: FPC 3.0.0 changed the definition of TInetSockAddr:\r
+ - http://www.freepascal.org/docs-html/rtl/sockets/tinetsockaddr.html\r
+ - http://www.freepascal.org/docs-html/rtl/sockets/sockaddr_in.html\r
+ Due to this, TInetSockAddr -> TLInetSockAddr4 / TLInetSockAddr6\r
+ Using our own types no matter what OS or compiler version will prevent future problems.\r
+ Adding "4" to non IPv6 record names improves code clarity }\r
+\r
+ {$ifndef mswindows}\r
+ {zipplet 20170204: Do we still need to support ver1_0? Perhaps a cleanup is in order.\r
+ For now keep supporting it for compatibility. }\r
+ {$ifdef ver1_0}\r
+ cuint16 = word;\r
+ cuint32 = dword;\r
+ sa_family_t = word;\r
{$endif}\r
{$endif}\r
\r
-\r
-\r
+ TLInetSockAddr4 = packed Record\r
+ family:Word;\r
+ port :Word;\r
+ addr :uint32;\r
+ pad :array [0..7] of byte; {zipplet 20170204 - originally this was 1..8 for some reason}\r
+ end;\r
+ \r
{$ifdef ipv6}\r
- {$ifdef ver1_0}\r
- cuint16=word;\r
- cuint32=dword;\r
- sa_family_t=word;\r
-\r
- TInetSockAddr6 = packed record\r
- sin6_family: word;\r
- sin6_port: word;\r
- sin6_flowinfo: uint32;\r
- sin6_addr: tin6_addr;\r
- sin6_scope_id: uint32;\r
- end;\r
- {$endif}\r
+ TLInetSockAddr6 = packed record\r
+ sin6_family: word;\r
+ sin6_port: word;\r
+ sin6_flowinfo: uint32;\r
+ sin6_addr: tin6_addr;\r
+ sin6_scope_id: uint32;\r
+ end;\r
{$endif}\r
+\r
+ {zipplet 20170204: I did not rename the unioned record. We might want to rename this to TLinetSockAddrv }\r
TinetSockAddrv = packed record\r
case integer of\r
- 0: (InAddr:TInetSockAddr);\r
+ 0: (InAddr:TLInetSockAddr4);\r
{$ifdef ipv6}\r
- 1: (InAddr6:TInetSockAddr6);\r
+ 1: (InAddr6:TLInetSockAddr6);\r
{$endif}\r
end;\r
Pinetsockaddrv = ^Tinetsockaddrv;\r
\r
type\r
- tsockaddrin=TInetSockAddr;\r
-\r
-\r
+ tsockaddrin=TLInetSockAddr4;\r
\r
{\r
bin IP list code, by beware\r
inAddr.InAddr.family:=AF_INET;\r
inAddr.InAddr.port:=htons(strtointdef(port,0));\r
inAddr.InAddr.addr:=addr.ip;\r
- result := sizeof(tinetsockaddr);\r
+ result := sizeof(tlinetsockaddr4);\r
end else\r
{$ifdef ipv6}\r
if addr.family = AF_INET6 then begin\r
inAddr.InAddr6.sin6_family:=AF_INET6;\r
inAddr.InAddr6.sin6_port:=htons(strtointdef(port,0));\r
inAddr.InAddr6.sin6_addr:=addr.ip6;\r
- result := sizeof(tinetsockaddr6);\r
+ result := sizeof(tlinetsockaddr6);\r
end;\r
{$endif}\r
end;\r
function inaddrsize(inaddr:tinetsockaddrv):integer;\r
begin\r
{$ifdef ipv6}\r
- if inaddr.inaddr.family = AF_INET6 then result := sizeof(tinetsockaddr6) else\r
+ if inaddr.inaddr.family = AF_INET6 then result := sizeof(tlinetsockaddr6) else\r
{$endif}\r
- result := sizeof(tinetsockaddr);\r
+ result := sizeof(tlinetsockaddr4);\r
end;\r
\r
{internal}\r
\r
getmem(output,sizeof(taddrinfo));\r
if assigned(prev) then prev.ai_next := output;\r
- getmem(output.ai_addr,sizeof(tinetsockaddr));\r
+ getmem(output.ai_addr,sizeof(tlinetsockaddr4));\r
if servname <> nil then output.ai_addr.InAddr.port := htons(strtoint(servname)) else output.ai_addr.InAddr.port := 0;\r
output.ai_addr.InAddr.addr := longint(addrlist^^);\r
inc(integer(addrlist),4);\r
output.ai_family := af_inet;\r
output.ai_socktype := 0;\r
output.ai_protocol := 0;\r
- output.ai_addrlen := sizeof(tinetsockaddr);\r
+ output.ai_addrlen := sizeof(tlinetsockaddr4);\r
output.ai_canonname := nil;\r
output.ai_next := nil;\r
prev := output;\r