Identifying active network interface

后端 未结 5 1920
走了就别回头了
走了就别回头了 2020-12-01 02:30

In a .NET application, how can I identify which network interface is used to communicate to a given IP address?

I am running on workstations with multiple network in

5条回答
  •  情歌与酒
    2020-12-01 02:35

    Just to give a complete picture: another approach would be to use Socket.IOControl( SIO_ROUTING_INTERFACE_QUERY, ... )

    ConferenceXP includes rather comprehensive function wrapping this, works with IPv4/6 and multicast addresses: https://github.com/conferencexp/conferencexp/blob/master/MSR.LST.Net.Rtp/NetworkingBasics/utility.cs#L84

提交回复
热议问题