Hi,
Can someone explain what's happening here, apparently it is over the internet, but no good explanation

Code:
struct in_addr {
  in_addr_t   s_addr;           /* 32-bit IPv4 address */
                                /* network byte ordered */
};

struct sockaddr_in {
  uint8_t         sin_len;      /* length of structure (16) */
  sa_family_t     sin_family;   /* AF_INET */
  in_port_t       sin_port;     /* 16-bit TCP or UDP port number */
                                /* network byte ordered */
  struct in_addr  sin_addr;     /* 32-bit IPv4 address */
                                /* network byte ordered */
  char            sin_zero[8];  /* unused */
};
struct sockaddr {
  uint8_t      sa_len;
  sa_family_t  sa_family;    /* address family: AF_xxx value */
  char         sa_data[14];  /* protocol-specific address */
};
From what I understand sockaddr and sockaddr_in have 2 fields in common the length and the family. struct sockaddr is some kind of base class.
What I don't understand is this notation.
Code:
bind(sockfd, (struct sockaddr *) &serv, sizeof(serv));
A pointer to sockaddr_in is treated a pointer to sockaddr. I understand that the pointer can fill in the length and family with no problems...but I don't understand how it would do so?

If sockAddr was the variable that holds the serv struct in bind how would it access the family and length
would it be sockAddr->sa_len or sockAddr->sin_len? If you have happened to use BSD api it'd be nice if you clarify what's happening thanks.