A machine has 2 NICs. Which one will be utilized when connecting to a socket?

后端 未结 3 2009
攒了一身酷
攒了一身酷 2021-01-02 19:13

Suppose I create a very simple socket connection, how can one programatically:

  1. Find out what interface (ip address / NIC) is being used.
  2. Force the ot
3条回答
  •  滥情空心
    2021-01-02 20:08

    You will find these links usefull, since the question doesn't provide a language, here's for the most common ones.

    Socket Programming in C

    Socket Programming in C#

    Socket Programming in Java

    Socket Programming in Python

    So, use any of these links and go to the languge you are using. Find the function for getting your host address or ip address and use the Bind method for the appropriet language. This will force the application to bind to that interface.

提交回复
热议问题