What is sin_zero for?

coolbean nieters at phobos.crd.ge.com
Wed Oct 17 23:27:26 AEST 1990



;
; The defininition of struct sockaddr_in in the <netinet/in.h>
; 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 <sys/socket.h> 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 at crd.ge.com
GE Corporate R&D	     UUCPnet:  uunet!crd.ge.com!nieters	       
Schenectady, NY 12301	     BELLnet:  (518) 387-5187



More information about the Comp.unix.questions mailing list