Re: [twsocket] LocalIPList on Mac
> I attached a spreadsheet with the results. The mailing list does not widely distribute massive attachments, it's low volume text only, please email it directly. I can fix the Windows issues, but you'll need to look at Mac stuff. Angus Original Message *Subject:* Re: [twsocket] LocalIPList on Mac *From:* "Bill Florac" *To:* "'ICS support mailing'" *Date:* Sun, 21 Jan 2018 00:18:01 -0600 Angus, I finally got around to test this. I attached a spreadsheet with the results. I ran LocalIPList() with each socket family option. I also showed the results of IcsGetInterfaceList(). PC is running windows 10, Mac is running High Sierra LocalIPList: MAC - Missing second IPv4 address if called with no parameters - Returns duplicate entries PC - Missing second IPv6 address BOTH Returns IPv6 link-local address but not IPv4. IcsGetInterfaceList: PC - Missing IPv6 addresses So if you don't care about IPv6, link-local and filter any duplicates, it seems to work! Bill -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Wednesday, January 3, 2018 6:32 AM To: twsocket@lists.elists.org Subject: Re: [twsocket] LocalIPList on Mac > 1) It seems that IcsGetInterfaceList() would fail if, for some odd > reason, the computer only had IPv6 interfaces. This would only be on Windows not MacOS, and I suspect it's impossible to install Windows without IPv4, too much stuff is dependent on it. > 2) This is my function to replace LocalIpList(). Not sure we need to replace it, what is the advantage of using IcsGetInterfaceList over the existing code (but see below)? > 3) As to the original LocalIPList() function, it seems that the code > at the top where it checks for ASocketFamily is not needed code in the > "else" section handles IPv4 just fine The 'else' stuff only works on Windows Vista and later, but not on Windows XP which still needs GetHostByName. While we don't officially support Windows XP or 2000, we also don't want to deliberately break ICS from working on them. But since GetHostByName is deprecated since Vista, I've changed the code so it's now only used for Windows XP and earlier, and never for MacOS, which should resolve your original problem. Or are you saying that GetAddrInfo only returns a single IP on MacOS as well? Testing on Windows 10, I see multiple IPv4 and IPv6 addresses using both LocalIpList and IcsGetInterfaceList, and no duplicates. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] LocalIPList on Mac
Angus, I finally got around to test this. I attached a spreadsheet with the results. I ran LocalIPList() with each socket family option. I also showed the results of IcsGetInterfaceList(). PC is running windows 10, Mac is running High Sierra LocalIPList: MAC - Missing second IPv4 address if called with no parameters - Returns duplicate entries PC - Missing second IPv6 address BOTH Returns IPv6 link-local address but not IPv4. IcsGetInterfaceList: PC - Missing IPv6 addresses So if you don't care about IPv6, link-local and filter any duplicates, it seems to work! Bill -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Wednesday, January 3, 2018 6:32 AM To: twsocket@lists.elists.org Subject: Re: [twsocket] LocalIPList on Mac > 1) It seems that IcsGetInterfaceList() would fail if, for some odd > reason, the computer only had IPv6 interfaces. This would only be on Windows not MacOS, and I suspect it's impossible to install Windows without IPv4, too much stuff is dependent on it. > 2) This is my function to replace LocalIpList(). Not sure we need to replace it, what is the advantage of using IcsGetInterfaceList over the existing code (but see below)? > 3) As to the original LocalIPList() function, it seems that the code > at the top where it checks for ASocketFamily is not needed code in the > "else" section handles IPv4 just fine The 'else' stuff only works on Windows Vista and later, but not on Windows XP which still needs GetHostByName. While we don't officially support Windows XP or 2000, we also don't want to deliberately break ICS from working on them. But since GetHostByName is deprecated since Vista, I've changed the code so it's now only used for Windows XP and earlier, and never for MacOS, which should resolve your original problem. Or are you saying that GetAddrInfo only returns a single IP on MacOS as well? Testing on Windows 10, I see multiple IPv4 and IPv6 addresses using both LocalIpList and IcsGetInterfaceList, and no duplicates. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] LocalIPList on Mac
> 1) It seems that IcsGetInterfaceList() would fail if, for some > odd reason, the computer only had IPv6 interfaces. This would only be on Windows not MacOS, and I suspect it's impossible to install Windows without IPv4, too much stuff is dependent on it. > 2) This is my function to replace LocalIpList(). Not sure we need to replace it, what is the advantage of using IcsGetInterfaceList over the existing code (but see below)? > 3) As to the original LocalIPList() function, it seems that > the code at the top where it checks for ASocketFamily is not > needed code in the "else" section handles IPv4 just fine The 'else' stuff only works on Windows Vista and later, but not on Windows XP which still needs GetHostByName. While we don't officially support Windows XP or 2000, we also don't want to deliberately break ICS from working on them. But since GetHostByName is deprecated since Vista, I've changed the code so it's now only used for Windows XP and earlier, and never for MacOS, which should resolve your original problem. Or are you saying that GetAddrInfo only returns a single IP on MacOS as well? Testing on Windows 10, I see multiple IPv4 and IPv6 addresses using both LocalIpList and IcsGetInterfaceList, and no duplicates. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] LocalIPList on Mac
> I'm not sure I am verse enough at the lower level code to offer > an opinion as to what is "correct" or not. However, just in case > someone sees this in a future thread search, here are my thoughts: Thanks for that lot, I will look at it, but not until next year. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] LocalIPList on Mac
Angus I'm not sure I am verse enough at the lower level code to offer an opinion as to what is "correct" or not. However, just in case someone sees this in a future thread search, here are my thoughts: 1) It seems that IcsGetInterfaceList() would fail if, for some odd reason, the computer only had IPv6 interfaces. It tries to create an AF_INET socket and raises an exception if it fails. Perhaps if should also test an IF_NET6 socket and only raise an exception of BOTH fail. I'll gladly code and submit this change if anyone knows if this is a real possibility. 2) This is my function to replace LocalIpList(). The "uses" clauses is only need because I run this from my app, not from the IPC components and its include files. I have tests to exclude local addresses based on the string. There may be a better performance if this was done on the numeric address values. {$IFDEF POSIX} uses Posix.SysSocket; {$ENDIF} ... {.DEFINE INCLOCAL} {.$DEFINE INCNET6} procedure MyLocalIpList(StrList: TStrings); {$IFNDEF POSIX} const AF_INET = 2; { internetwork: UDP, TCP, etc. } AF_INET6= 23; { Internetwork Version 6 } {$ENDIF} var iList : TInterfaceList; I : Integer; s: string; begin if not Assigned(StrList) then exit; StrList.Clear; iList := TInterfaceList.Create; try IcsGetInterfaceList(iList); for I := 0 to IList.Count -1 do begin if IList[I]^.iiAddress.AddressIn.sin_family = AF_INET then begin s := String(WSocket_inet_ntoa(IList[I]^.iiAddress.AddressIn.sin_addr)); {$IFNDEF INCLOCAL} if s <> '127.0.0.1' then {$ENDIF} StrList.Add(s); {$IFDEF INCNET6} end else begin if IList[I]^.iiAddress.AddressIn6.sin6_family = AF_INET6 then begin s := WSocketIPv6ToStr(@IList[I]^.iiAddress.AddressIn6); {$IFNDEF INCLOCAL}if copy(s,1,4) <> 'fe80' then {$ENDIF} StrList.Add(s); end; {$ENDIF} end; end; finally iList.Free; end; end; 3) As to the original LocalIPList() function, again not being the verse enough to "officially" suggest a correction, but it seems that the code at the top where it checks for ASocketFamily is not needed as the code in the "else" section handles IPv4 just fine. If you get rid of this, it does not cause the function that fails on a Mac (GetIpList) and seems to work just fine with the caveat that it returns duplicate address values. Maybe someone with better knowledge of the underbelly of the stack would understand this. If this is expected, we simple could ignore duplicates. //WRF - this conditional test is can be removed, keeping only "else" //if ASocketFamily = sfIPv4 then begin //phe := WSocketGetHostByName(LocalHostName); // if phe <> nil then //GetIpList(Phe, IPList); //end //else begin //end; Bill -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Wednesday, December 20, 2017 2:53 AM To: twsocket@lists.elists.org Subject: Re: [twsocket] LocalIPList on Mac > It seems that LocalIPList on a Mac (POSIX) returns only a single IP > address Note that it seems that gethostbyname() is also a documented > as depreciated function. > I switched and used IcsGetInterfaceList() which seems to work. I can > toss out the AF_INET6 records and the local loop back. Note the local > loop back is only return on the Mac, not windows. The low level code in wsocket is quite convoluted and hard to follow, due to support for multiple OSs and platforms. IcsGetInterfaceList does not currently appear to be used by any ICS components or samples, but I assume was well tested when originally written, and it was an oversight to not update wsocket to use it. If you let me have your modified unit, I'll update it in SVN. But please do test it carefully, to make sure it works as expected. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] LocalIPList on Mac
> It seems that LocalIPList on a Mac (POSIX) returns only a single > IP address > Note that it seems that gethostbyname() is also a documented as > depreciated function. > I switched and used IcsGetInterfaceList() which seems to work. I > can toss out the AF_INET6 records and the local loop back. Note > the local loop back is only return on the Mac, not windows. The low level code in wsocket is quite convoluted and hard to follow, due to support for multiple OSs and platforms. IcsGetInterfaceList does not currently appear to be used by any ICS components or samples, but I assume was well tested when originally written, and it was an oversight to not update wsocket to use it. If you let me have your modified unit, I'll update it in SVN. But please do test it carefully, to make sure it works as expected. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be