Page 4 of 4
Posted: Sun Oct 12, 2008 11:33 pm
by Psychophanta
Have you tried something like 169.45.0.2.2 with your code
Well:
http://www.purebasic.fr/english/viewtopic.php?p=263344
Posted: Mon Oct 13, 2008 2:12 am
by Little John
Psychophanta wrote:Have you tried something like 169.45.0.2.2 with your code

The first version of the code had counted the number of dots, in the second version I forgot to do so. Now corrected.
Regards, Little John
Find IP in Text File
Posted: Mon Oct 13, 2008 1:48 pm
by elfo116
Thanks to all for the contributed ideas.
Ultimately I have chosen for the best solution and have updated to the version 4.2.

Posted: Mon Oct 13, 2008 1:52 pm
by Kaeru Gaman
Posted: Mon Dec 22, 2008 3:59 pm
by SFSxOI
Sometimes an IP formatted like 139.023.198.123 with the leading 0 can be seen in some TCP/IP implementations when they are presented for physical viewing in some sort of console or GUI view or some sort of dump to say for example a txt file or they can be used that way in configuration files for example. But...when they are fed into the packet and sent the leading 0's is/are stripped so an IP address 139.023.198.123 is actually sent to the tcp/ip packet as 139.23.198.123 but may be 're-paded' in the tcp/ip implementation in some cases to add back the leading 0's to fill a packet space of some sort if the requirement is to have all octet spaces filled. If the IP address is something like a series of 0's then the leading 0's are stripped until at least one character (or non-zero) character is left before or after a '.' (dot) when actually sent You can see this yourself with the ping command in a windows command prompt, you can put in 127.000.000.1, and when it seems to change it to 127.0.0.1 ping is actually not changing it, its showing you what was actually sent in the packet and is showing you the change it made to represent what would actually be sent of a true IP address which does not contain leading 0's.
For example, an IP address of 075.012.123.255 while visually or graphically represented as 075.012.123.255 will actually be sent as 75.12.123.255.
So yes, there are Ip addresses with leading 0's, but only visually or graphically represented, but not actually sent or used.
Posted: Mon Dec 22, 2008 4:21 pm
by pdwyer
I'm confused... (or you are

)
when IP's are "fed into a packet" they are binary and not text so the zero's are irrelevent, it's just 4 bytes in a dword. I'm not sure if this is what you meant though
I've seen some apps use leading zeros in log files that have special built in parsers and they have the zeros to line up all of the octets so string parsing is faster (these logs can get very long). They don't have to search for the dots they just grab the three chars where they are expected to be. These are controlled circumstances of course
Posted: Mon Dec 22, 2008 4:35 pm
by SFSxOI
pdwyer wrote:I'm confused... (or you are

)
when IP's are "fed into a packet" they are binary and not text so the zero's are irrelevent, it's just 4 bytes in a dword. I'm not sure if this is what you meant though
I've seen some apps use leading zeros in log files that have special built in parsers and they have the zeros to line up all of the octets so string parsing is faster (these logs can get very long). They don't have to search for the dots they just grab the three chars where they are expected to be. These are controlled circumstances of course
Yes, they are binary when sent, i'm just saying they are not actually sent with the leading 0's with the leading 0's being stripped when its fed to the tcp/ip packet at first. I was trying to stay in context with the thread in regards to how the errors are returned from the code when incorrect information is fed to the code given. And I tallking in reference to the common occurances seen in windows systems. Yes in logs they can be represented with the leading 0's and thats the graphical or visual representation I was refering to but that doesn't always represent that leading 0's were sent as it could just be due to what ever produces the log putting the 0's back in for formatting purposes in the log. Leading 0's in an IP address are meant to be interpeted as nothing, meaning they have no effect on the actual destination routing because they are stripped in translation for use in TCP/IP normally.
So were basically saying the same thing almost because leading 0's have no effect or value for use in the actual addressing, i just didn't say it as well maybe.
Posted: Mon Dec 22, 2008 5:01 pm
by Kaeru Gaman
neither there are "no leading zeros" nor there are "leading zeros" in a binary format, because it has no decimal digits.
oh... btw... thank you for exhuming this disgusting thread... I almost had a nice evening.
Posted: Tue Dec 23, 2008 12:52 am
by pdwyer