What is AF_INET, and why do I need it?

sockets

Solution

`AF_INET` is an address family that is used to designate the type of addresses that your socket can communicate with (in this case, Internet Protocol v4 addresses). When you create a socket, you have to specify its address family, and then you can only use addresses of that type with the socket. The Linux kernel, for example, supports 29 other address families such as UNIX (`AF_UNIX`) sockets and IPX (`AF_IPX`), and also communications with IRDA and Bluetooth (`AF_IRDA` and `AF_BLUETOOTH`, but it is doubtful you'll use these at such a low level).

For the most part, sticking with `AF_INET` for socket programming over a network is the safest option. There is also `AF_INET6` for Internet Protocol v6 addresses.

Problem

I'm getting started on socket programming, and I keep seeing this `AF_INET`. Yet, I've never seen anything else used in its place. My lecturers are not that helpful and just say "You just need it". So my questions: - What is the purpose of `AF_INET`? - Is anything else ever used instead of it? - If not, why is it there? For possible changes in the future? - If so, what and why?

Original source

Related problems