in_addr_t
, defined as a part of the BSD sockets API.struct sockaddr_in
, which e.g. also includes the port.struct sockaddr
as a "base type").What is actual type for subnet? in_addr_t is like a one ip address.Don't roll your own! For IPv4 addresses, there'sin_addr_t
, defined as a part of the BSD sockets API.
You'd typically use it as part of astruct sockaddr_in
, which e.g. also includes the port.
In fact, try to write your code independent of the protocol used, that's how the sockets API was originally designed (withstruct sockaddr
as a "base type").
edit: I'd recommend using higher-level API calls like getaddrinfo(3)/getnameinfo(3) to work with socket addresses.
in_addr_t
used as a bitmask, or a simple integer giving the prefix length (number of initial 1-bits in the bitmask).