troubleshooting Question

how is the sockaddr struct defined

Avatar of justinl525
justinl525 asked on
CLinux OS DevLinux Networking
8 Comments1 Solution1782 ViewsLast Modified:
I am teaching myself socket programming in C.  I understand how to do the stuff I need to get sockets working and cummunicating.  My question is more about how something underlying works.

in most socket functions you have to cast your address structure to a generic pointer to a sockaddr struct.

My question is how does the definition for the sockaddr struct work and what does the compiler do when it comes upon this "(struct sockaddr *)sockaddr_*"

I have looked at socket.h and I find this a transparent union...  I dont understand much of the transparent union but I am trying to see how that union can be used to cast different size/variable size address structures to a generic sockaddr struct.  

Any one have an idea?
phoffricSoftware Engineering and Matlab Analyst

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros