Let's say I have wifi, ethernet lan, and Hamachi turned on on my PC.

They are all connected.

My applications send data through them.

Terminology question: My applications send data to these network adapters, or network interface controllers or network interfaces. That is these 3 technologies create network adapters (NIC) for my applications to communicate to the network? Which is the correct term (network adapter, network interface, NIC)?

Each of these network adapters (?) is assigned an IP address (one or more).

How does my application know to which adapter to send data? Is there a default adapter selected by the OS, but the application can additionally choose the adapter. I think in Java (and other programming languages) when you create a socket you can specify the local IP address, and this must be one from the addapters's assigned?

This also means the data sent will use the respective IP source address in the IP package depending on the adapter used?

  • You have have multiple network connections and use route to direct traffic. – DavidPostill Apr 26 '18 at 16:46
  • What operating system? Edit your question. – Ramhound Apr 26 '18 at 17:05
  • @Ramhound I was asking in general. But I work with Windows 7 and Ubuntu 16. – croraf Apr 27 '18 at 11:29

Outside of very specific cases dealing with protocols below TCP or UDP, applications don't send data to a specific network adapter, they send the data to a specific remote network address. It is then up to the OS to figure out which adapter the resulting packet needs to be sent from to reach its destination, although each OS does this a bit differently (although the general terminology is mostly the same, you can search for information about 'routing tables' for your OS of choice for more info).

In most programming languages, you can explicitly bind a socket to a given address. Most of the time, this needs to be an address assigned to a local network adapter (in which case all the traffic from that socket will go out via that adapter), though in some cases it is possible to bind to a non-local address (this is used in some situations for certain types of transparent proxy or captive portal).

  • Regarding your first paragraph. Isn't it that the socket is bound to a specific network adapter during it's creation (even if you don't explicitly specify the binding local address). Then to whatever remote address you send through this socket it will use the previously bound network adapter? – croraf Apr 27 '18 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.