在VS C ++中使用winsock选择以太网适配器 [英] Selecting ethernet adapter using winsock in VS C++

查看:145
本文介绍了在VS C ++中使用winsock选择以太网适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要发现连接到Windows PC的设备。该PC可能有多个以太网适配器。这是通过发送设备回复的广播UDP / IP数据包来完成的。通常,一个适配器连接到WAN,另一个适配器连接到LAN。如果Windows'使用'LAN作为主适配器,或者WAN适配器被禁用,一切顺利。如果没有,则回复不会使其返回到应用程序(Wireshark验证设备是否接收并回复请求)。如何强制Windows使用LAN适配器广播发现请求并收到回复?



我尝试过:



我尝试了多次网络搜索而没有任何有意义的结果。

I have an application that needs to discover devices connected to a Windows PC. That PC may have multiple Ethernet adapters. This is done by sending a broadcast UDP/IP packet to which the device replies. Typically one adapter is connected to a WAN and the other a LAN. If Windows 'uses' the LAN as the primary adapter, or the WAN adapter is disabled, all goes well. If not, the reply doesn't make it back to the application (Wireshark verifies that the device receives and replies to the request). How can I force Windows to use the LAN adapter for broadcasting the discovery request and receive the reply?

What I have tried:

I've tried multiple web searches with no meaningful results.

推荐答案

第一眼看到报价
How can I force Windows to use the LAN adapter for broadcasting the discovery request and receive the reply?





将构成一个可开发的安全漏洞尺寸得克萨斯州。通常由网络管理员来配置适配器,并且需要root / admin访问权限。



除此之外,每个适配器都有自己的IP地址。因此,知道该地址可以连接到有问题的适配器,只要有某种类型的服务器在该适配器后面运行,您就可以查询该服务器提供的任何内容。听起来你正在寻找桥接适配器:

https://en.wikipedia.org/wiki/Bridging_(networking)\"



would constitute an exploitable security hole sizeof Texas. It is usually up to network admins to configure adapters and requires root/admin access to do so.

Other than that each adapter has its own IP address. So knowing that address you can connect to the adapter in question and as long as there some type of server is running behind that adapter you can query it for whatever that server provides. It sounds like you searching for the bridge adapter:
"https://en.wikipedia.org/wiki/Bridging_(networking)"


听起来像你需要路由器。



PC(带一个物理适配器)进入路由器; (有线和/或无线)路由器依次连接到WAN和LAN。



对我来说,这比你描述的更典型 (2个NIC)。
Sounds like you need a router.

The PC (with ONE physical adapter) goes to the router; the (wired and / or wireless) router in turn is connected to the WAN and the LAN.

To me that is more "typical" than what you're describing (2 NICs).


这篇关于在VS C ++中使用winsock选择以太网适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆