Find IP in text ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post 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
elfo116
User
User
Posts: 39
Joined: Sun Oct 12, 2008 9:50 am
Location: CADIZ

Find IP in Text File

Post 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. :D
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

:lol:
oh... and have a nice day.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post 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.
Last edited by SFSxOI on Mon Dec 22, 2008 4:42 pm, edited 2 times in total.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

I'm confused... (or you are :P )

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
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

pdwyer wrote:I'm confused... (or you are :P )

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.
Last edited by SFSxOI on Mon Dec 22, 2008 5:21 pm, edited 2 times in total.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

:lol:
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Post Reply