C++ windows32的winsock UDP路由?
在使用Windows32的C++中,使用Windows套接字库,使用UDP,有一种方法可以将客户端路由信息提供给另一个客户端,以在客户端之间建立连接,而无需通过服务器进行路由
澄清:
服务器 - 等待计算机并提供路由信息 - 一个分离的服务器 客户端 - 发送确认请求并等待路由信息 - 普通用户计算机
,但是可以,所以它不可能向客户端提供路由信息以互连客户端而不需要通过服务器转发数据?
In C++ using Windows32 using windows socket library using UDP is there a way to give a client routing information to another client to establish a connection between clients without having to route through the server
Clarification:
server - waits for computers and gives routing info - a detached server
client - sends a ack request and waits for routing info - a normal user computer
but ok so its not posible to give routing info to clients to interconnect clients without requiring the data to be forwarded through the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的回答:不。
长答案:无论您的 UDP 数据包中包含什么信息,在传输层它都只是另一个 IP 数据包,您的 NIC 会在其上添加适当的标头并将其发送出去。除非主机直接相互连接,否则网络拓扑将决定它必须经过多少跳(路由器/交换机)才能到达那里。
附录:
我不确定您所说的服务器是什么意思(我最初将其读为“路由器”,但您也可以轻松地谈论域名服务器(DNS))。如果您想避免 DNS 查找,可以通过直接提供 IP 地址(假设您知道)来轻松实现。然而,DNS 查找是一个一次性过程——一旦知道 IP 地址,DNS 主机就不会以任何方式参与路由 UDP 数据包。
Short answer: no.
Long answer: No matter what information you include in your UDP packet, at the transport layer it's just another IP packet, and your NIC will slap the appropriate headers on it and send it on its way. Unless the hosts are directly connected to each other, the network topology will dictate how many hops (routers/switches) it has to make to get there.
Addendum:
I'm not sure what you mean by server (I read it as "router" initially, but you could just as easily have been talking about a Domain Name Server (DNS)). If you are trying to avoid DNS lookup, you can easily do this by providing an IP address directly (assuming you know it). However, DNS lookup is a one-time process--once the IP address is known, the DNS host is not involved in routing your UDP packets in any way.
简短回答:否
详细回答:是 --- 但您必须使用 IPPROTO_IP,而不是 IPPROTO_UDP。使用setsockopt()中的IP_OPTIONS选项来设置源路由。
Short answer: no
Long answer: yes --- but you have to use IPPROTO_IP, not IPPROTO_UDP. Use IP_OPTIONS option in setsockopt() to set source routing.