Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!crdgw1!nieters From: nieters@phobos.crd.ge.com (coolbean) Newsgroups: comp.unix.questions Subject: Re: What is sin_zero for? Message-ID: Date: 17 Oct 90 13:27:26 GMT References: Sender: news@crdgw1.crd.ge.com Reply-To: nieters@desdemona.crd.ge.com Distribution: comp Organization: GE Corporate R&D, Schenectady, NY Lines: 36 In-reply-to: mjd@saul.cis.upenn.edu's message of 16 Oct 90 17:07:39 GMT ; ; The defininition of struct sockaddr_in in the ; files on our suns has four members, one of which is ; char sin_zero[8]; ; ; What is it for? This is an unused member whose sole purpose is to pad the structure out to 16 bytes. Similarly, the Xerox NS family has a "_zero" member struct sockaddr_ns { u_short sns_family; /* AF_NS */ struct ns_addr sns_addr; /* the 12-byte XNS address */ char sns_zero[2]; /* unused */ ^^^^^^^^^^^^^^^^^ }; total sizeof(struct sockaddr_ns) == 16 bytes. If you look in you'll find the definition for struct sockaddr which is 2 bytes of address family (sa_family) followed by "up to 14 bytes of direct address" (sa_data[14] ... a.k.a. protocol specific address.) Since system calls dealing with sockets (e.g. accept() ) take the generic (struct sockaddr *) argument, protocol specific structures (such as sockaddr_in, in this case) need to be padded out to the same size as the generic. hope this helps. --ed -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Ed Nieters INTERnet: nieters@crd.ge.com GE Corporate R&D UUCPnet: uunet!crd.ge.com!nieters Schenectady, NY 12301 BELLnet: (518) 387-5187