INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

sockaddr_storage and its usage in socket programming

sockaddr_storage and its usage in socket programming

(OP)
Hi people,

I am trying to understand the process of translating ipv4 code to support ipv6 protocol type. But it is very difficult for me to undersrand the following. If I have ipv4 code

struct sockaddr_in saddr;
bzero((char *) &saddr, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons((u_short) service);
saddr.sin_addr.s_addr = INADDR_ANY;

to make this structure to support pure ipv6 is necessary change sockaddr_in to sockaddr_in6, sin_family=AF_INET to sin6_family=AF_INET6, sin_addr to sin6_addr and , INADDR_ANY to in6addr_any, and get ipv6 compatible structure. But if we want to make address family independet application then we have to use sockaddr_storage which can storage all necessary for that purpose. I
cannot understand how to above code rewrite to be address familly independent. About sockaddr_storage structure you can read at web location

http://www.kame.net/newsletter/19980604/

In other words I just need some hint how above address dependent code rewrite using sockaddr_storage and make it and make it address independet.

Is there is someone who already did something similar and is willing to share her/his knowledge it will be highly valuated.

Thank you in advance

RE: sockaddr_storage and its usage in socket programming

I would assume that you would have to write a few wrapper functions to achieve that kinda stuff. If you couldd be a bit more specific in terms of any APIs may be i could help you out better?

Regards,
Harneet

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close