C ++ socket: addrinfo structure size

I am using eclipse with cygwin. The application has 64 bits. In cygwin, a structure is defined as:

struct addrinfo {
  int             ai_flags;         /* input flags */
  int             ai_family;        /* address family of socket */
  int             ai_socktype;      /* socket type */
  int             ai_protocol;      /* ai_protocol */
  socklen_t       ai_addrlen;       /* length of socket address */
  char            *ai_canonname;    /* canonical name of service location */
  struct sockaddr *ai_addr;         /* socket address of socket */
  struct addrinfo *ai_next;         /* pointer to next in list */
};

The result of sizeof (addrinfo) is 48. The size of socketlen_t is 4 bytes. The size of the int type is 4 bytes. The pointer has 8 bytes in a 64-bit application. The total byte is 44 (4 ints = 16 bytes, socket_len = 4 bytes, 3 pointers = 24; 20 + 4 + 24 = 44). I wonder why 4 bytes are missing? Are they for filling? I thought 44 bytes did not need to be aligned. Any thought?

Thanks for the reply in advance.

+4
source share
2 answers

, socklen_t. - 64 ( ) 64-. , ; , , .

, , , ( / ). , . , .

+3

" ", /Zp
,
Microsoft

+1

Source: https://habr.com/ru/post/1628673/


All Articles