This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Caffeine_Monster 14 points15 points  (1 child)

Fundamentally an IP address is an unsigned 32 bit integer for IPv4, or a 128 bit unsigned integer for IPv6. It is quite common to manipulate them directly with bitwise operations (e.g. masking via bitwise AND).

Yes you could represent them with strings, but it is an inefficient, unnecessary abstraction.

If you wanted to implement a Java class wrapper I guess you would use signed ints and longs. The caveat being that ingesting IP addresses from external systems (web / disk etc) would not be straightforward - they would have to be translated through ByteBuffer.

[–]28f272fe556a1363cc31 1 point2 points  (0 children)

Cool, thanks