[fpc-pascal] Test for valid ip address

Koenraad Lelong fpascal1 at de-brouwerij.be
Thu Jul 28 12:45:48 CEST 2016


Op 28-07-16 om 10:38 schreef Christo:

> The in_addr IP address type is a packed record of byte, so if an IP
> address part larger than 255 is encountered in a string it will be
> truncated when copied to the byte record using StrToHostAddr.  This
> probably means you have to use some other means of detecting an invalid
> address, or add a check for (tmpAddress <> IPAddressStr) to cater for
> your situation.

Thanks,

I used the check :
(tmpAddress <> IPAddressStr)
in stead of
(tmpAddress='0.0.0.0')

Koenraad




More information about the fpc-pascal mailing list