问题描述
这可能更像是一个网络问题,而不是Python问题,但
如果有人用Python的套接字完成这个问题会很高兴
模块。除了一个通常从c.l.py获取更多信息而不是
其他地方:)
我有一个静态公共服务器IP和NAT后面的客户端。我希望
能够将UDP数据包从服务器发送到客户端。所以我需要做的是打开一个漏洞。在NAT中,让服务器知道它可以发送数据包的客户端的目标IP和端口。
现在我已经读过你的某个地方了可以在
相同端口上运行TCP和UDP。不确定这是否属实。它是一个合理的解决方案
启动从客户端到服务器的TCP连接,并以某种方式
(?)让服务器弄清楚客户端如何连接?然后
通过相同的(IP,端口)向客户端发送UDP?
This is probably more of a networking question than a Python one, but
it would be nice to know if someone has done this with Python''s socket
module. And besides one usually gets more information from c.l.py than
anywhere else :)
I have a server with a static "public" IP and a client behind a NAT. I
would like to send UDP packets from the server to the client. So what I
need to do is open up a "hole" in the NAT and let the server know the
target IP and port of the client where it can send its packets.
Now I have read somewhere that you can have TCP and UDP running on the
same port. Not sure if this is true. Would it be a reasonable solution
to initiate a TCP connection from the client to the server and somehow
(?) let the server figure out how the client is connecting? And then
send UDP to client over the same (IP, port)?
推荐答案
启动从客户端到服务器的UDP连接,并让
服务器将UDP数据包发回到你在
" recvfrom"结果。
Initiate an UDP connection from the client to the server and have the
server send back the UDP packets to the address you get in the
"recvfrom" result.
没有UDP连接这样的东西,所以我不会理解你的'b $ b'建议。
-
格兰特爱德华兹格兰特哇!通过MEER biz doo
在SCHOIN
...
visi.com
There''s no such thing as a "UDP connection", so I don''t
understand what you''re suggesting.
--
Grant Edwards grante Yow! By MEER biz doo
at SCHOIN...
visi.com
这篇关于UDP数据包到NAT后面的PC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!