Reputation: 1843
"INADDR_ANY binds the socket to all available interfaces."
This is the statement i Encountered.I found it here
What is interface here? Is it a port number or something else?
And another question is
Is interface and channel or one and same?
Upvotes: 1
Views: 816
Reputation: 5163
Usually your host (your computer) has more than one interfaces. For example, (older) computer without network would have only IPv4 loopback
interface.
If you add and configure IPv4 network to that PC, you'll get another interface: eth0
, or net0
or something similar.
When you install VPN, it will create you yet another interface, as instead of sending packets into unsecured network, you send it into logical VPN interface, and that one forwards data to eth0
after some processing.
Every time, when you add a hardware link (with driver) to a network, or create logical network, it creates you a new interface. For example, if you use VMVare, and create virtual machine, the system would provider you some set of interfaces needed to route data between your host, network, and virtual machine.
When routing IPv4, every interface is assigned IPv4 address. Even loopback (127.0.0.1). The address can be static, or obtained from server when your system boots.
So you can listen only on one interface. For example, if you bind to loopback, you will not be able to access any network, and network hosts will not be able to access your socket (assuming routing is not broken). But you connect multiple processes on your host to each other.
If you bind to particular network interface, it means you want to work with systems, that are connected to that network (directly or indirectly).
If you bind to any
, for server sockets it means you let system to accept connections from anywhere
, considering that anywhere
can ping you.
Upvotes: 2
Reputation: 11414
Examples for interfaces:
etc. If you´re writing a socket server, you can choose
where the client connections may come from.
Only from a virtual machine, but no real computer outside?
Only wifi, but no cable-bound LAN? Or just all together?
Upvotes: 0
Reputation: 25865
As per my understanding the socket interface is something like this
Also something like this also
A network interface is the point of interconnection between a computer and a private or public network. A network interface is generally a network interface card (NIC), but does not have to have a physical form. Instead, the network interface can be implemented in software.
For example, the loopback interface (127.0.0.1 for IPv4 and ::1 for IPv6)
is not a physical device but a piece of software simulating a network interface. The loopback interface is commonly used in test environments
Upvotes: 0