Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9127275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:14:46+00:00 2026-06-17T07:14:46+00:00

If we use a 32-bit integer to store an IPv4 address, then the byte

  • 0

If we use a 32-bit integer to store an IPv4 address, then the byte order of the integer must be considered.

However, as there is no built-in 128-bit integer type under almost all platforms, an IPv6 address must be stored into a byte array, so, I think the byte order is no longer a problem.

Am I correct? Or is there a corresponding function htonlXXX for IPv6?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:14:47+00:00Added an answer on June 17, 2026 at 7:14 am

    IPv6 does require network byte order for ipv6 addresses. hton and ntoh are all about converting the address from how you have it stored in your code, to how it needs to be stored in the packet (and vice-versa). So the issue becomes how you have it stored in your code.

    Also the definition of an IPv6 address in code can allow more ways to address it than just an array of bytes:

    struct in6_addr
    {
        union 
        {
            __u8 u6_addr8[16];
            __u16 u6_addr16[8];
            __u32 u6_addr32[4];
        } in6_u;
    #define s6_addr in6_u.u6_addr8
    #define s6_addr16 in6_u.u6_addr16
    #define s6_addr32 in6_u.u6_addr32
    };
    

    IPv6 addresses, to the user, are represented as 8 16-bit values. If you have the address stored as 8 16-bit values in your code, then you will need to use htons on each 16 bit value as you place it into the packet using the u6_addr16[] array, and use ntohs as you retrieve each 16-bit value from u6_addr16[].

    These links are helpful:

    http://msdn.microsoft.com/en-us/library/ee175867.aspx

    http://en.wikipedia.org/wiki/IPv6_address (especially the diagram at top right)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following snippet to build a 32 bit integer to use with
I use bit.ly to shorten my urls. My problem - paramters are not passed.
How to use bit-addresable(assembly) in java? e.g. int a = 13; int b =
I use this bit of code to feed some data i have parsed from
Should I use 32-bit Eclipse or 64-bit Eclipse for Android development? Im on a
I could use a bit of help with this, as i am new to
I am trying to use a bit of code I found at the bottom
we have a particle detector hard-wired to use 16-bit and 8-bit buffers. Every now
Is it possible to use bit functions in queries using Seam's HibernateEntityQuery? I've just
Many data mining algorithms/strategies use vector representation of data records in order to simulate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.