Data Type - socklen_t, sa_family_t

I am creating a simple socket web server using sys / socket.h lib and I stumbled upon socklen_tand sa_family_tand I am a bit confused about what their actual purpose is.

Definition:

  • sa_family_t - unsigned type of integral.
  • socklen_t - An unsigned opaque integral type of at least 32 bits in length.

Now I understand that the <sys/socket>lib declares three structures ( sockaddr, msghdr, cmsghdr), which contain members of announcing these data types.

  • sa_family_t sa_family address family
  • socklen_t msg_namelen size of address
  • socklen_t msg_controllen ancillary data buffer len
  • socklen_t cmsg_len data byte count, including the cmsghdr

But why create new data types, why not just use a data type unsigned int?

+4
source share
1 answer

, , unsigned int.

, , , , int .

+4

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


All Articles