我有一个多宿主机器,需要回答这个问题:
I have a multi-homed machine and need to answer this question:
由于远程机器,它的本地接口适用于用于通信的IP地址。
Given an IP address of the remote machine, which local interface is appropriate to use for communication.
这需要在C#中完成的。我可以使用Win32 Socket和SIO_ROUTING_INTERFACE_QUERY,但环顾四周的.NET Framework文档中我还没有找到一个等效为它做查询。
This needs to be done in C#. I can do this query using Win32 Socket and SIO_ROUTING_INTERFACE_QUERY but looking around in the .net framework documentation I haven't found an equivalent for it.
感谢
我不知道这一点,所以才不得不在Visual Studio对象浏览器一看,它看起来像你可以从的System.Net.Sockets 命名空间。
I didn't know about this, so just had a look in the Visual Studio Object browser, and it looks like you can do this from the System.Net.Sockets
namespace.
在该命名空间是插槽
类,它包含了一个方法的IOControl
。其中一个重载这种方法使用了一个的IOControl code
(枚举在同一个命名空间),其中包含了'RoutingInterfaceQuery的条目。
In that namespace is a Socket
class which contains a method IOControl
. One of the overloads for this method takes an IOControlCode
(enum in the same namespace) which contains an entry for `RoutingInterfaceQuery'.
我会尽量把一些code一起作为一个例子吧。
I'll try and put some code together as an example now.
上一篇:RuntimeBinderException与Newtonsoft.Json解析JSON时Newtonsoft、RuntimeBinderException、JSON、Json
下一篇:WPF .NET 4中 - OneWayToSource结合只写属性适用于某些机器!怎么样?适用于、只写、属性、机器