Is there any function that will convert an IP address to LongINT and vice versa? I know both C and PHP have a standard function for this but canot find any in Pascal.
I've found this great library that claims to do this, inetaux.pas. Though it does a good job reordering the byte order the implementation of the functions StrToAddr() and AddrToString() seem to be flawed, or at least my implementation of them:
sipLng := StrToAddr(sIp);
eipLng := StrToAddr(eIp);
j += 1;
sipLng += 1;
writeln(sipLng,' ',eipLng,' ',j);
until sipLng = eipLng;
Here is a link to the library:http://www.bastisoft.de/pascal/sources/pasinet.zip
All the writeln() calls are just for debugging. I can't really look at the library and understand it too well. As I'm a newb to Pascal.
I mostly use Free Pascal on Mac and Unix, and Delphi for Windows. I've looked through the documentation of Free Pascal and couldn't find anything.
EDIT: it looks like the function is flawed. Since they each are turned into a signed LongInt sipLng is actually a greater value than the ending IP address, in this case eipLng().
Here is an example with sipLng at 192.168.2.110 and eipLng set to 192.168.2.200
if I understand this correctly the loop is infinite because the starting ip address was converted to a higher value than the ending ip address.
How do most other developers solve this problem with FreePascal? I'm sure it comes up a lot.