On 28/07/16 10:14, Koenraad Lelong wrote:
I need a way to test if an string containing an ipv4-address is really an ipv4-address. I tried tmpAddress:=HostAddrToStr(StrToHostAddr(IPAddressStr)); writeln(tmpAddress); if (tmpAddress='0.0.0.0') then begin writeln('Error in IP-address'); IPAddressStr:=tmpAddress; end; When I enter 192.168.185.297 (i.e. not a valid ipv4 address) in IPAddressStr I get 192.168.185.41 not the expected error-message.
You can add a multiple of 256 to any octet of an IPv4 address in most programs. Try it in your browser, it will probably also work.
Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal