Adobe AIR、URLRequest 和本地端口
我正在考虑使用 Adobe AIR 编写一个应用程序,但我想首先弄清楚这对于该平台是否可行。 (对于 Flash 和 AIR 来说大多是新手)
我想做的是提前知道 URLRequest
将使用什么本地端口。如果可能的话,我想保持连接打开,并继续使用相同的套接字。
我基本上想要完成的是提前进行一些 NAT 遍历和端口协商。一旦我协商了客户端和服务器,我希望它们能够连接并基本上以点对点的方式使用 HTTP 来流媒体,就像这个示例:
var s = new air.Sound();
var url = "http://www.example.com/sounds/bigSound.mp3";
var req = new air.URLRequest(url);
var context = new air.SoundLoaderContext(8000, true);
s.load(req, context);
s.play();
问题是我看不到这种情况发生,除非我可以从 AIR 获取有关其计划使用哪些端口的一些信息。我可以创建自己的 Socket
连接到服务器并使用它们,但我需要一种方法来利用声音框架以相同的方式从套接字进行流式传输。
有想法吗?想法?谢谢!
I'm looking at writing an app with Adobe AIR, but I wanted to figure out if this is feasible with the platform first. (Mostly new to Flash and AIR)
What I would like to do is know ahead of time what local port a URLRequest
will be using. If possible, I would like to hold a connection open even and keep using the same socket.
What I'm basically trying to accomplish is doing some NAT-Traversal and port negotiation ahead of time. Once I have both the client and the server negotiated, I'd like them to connect and basically use HTTP in a peer-to-peer way to stream media, like this sample:
var s = new air.Sound();
var url = "http://www.example.com/sounds/bigSound.mp3";
var req = new air.URLRequest(url);
var context = new air.SoundLoaderContext(8000, true);
s.load(req, context);
s.play();
The problem is that I don't see this happening unless I can get some information from AIR on what ports it's planning to use. I would be OK with creating my own Socket
connections to the server and using them, but I would need a way to leverage the Sound framework to stream in the same way from a socket.
Ideas? Thoughts? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使您设法猜测 AIR 将在您的设备上使用哪个端口,它也不会很有帮助,因为您的 NAT 很有可能会将其转换为另一个值IF您的 AIR 设备有一个私有 IP 地址。
如果您的 AIR 服务器具有公共 IP 地址,则不会发生此问题。大多数情况下,您可以将服务器的 NAT/路由器配置为按原样转发流量。来自 WAN 的端口扫描将快速告诉您使用了哪个端口。
如果您想要“劫持”由 AIR 本身创建的出站连接,那么您可能会尝试让它联系您已实现的特殊服务器对等点,该服务器将转发来自它的流量。不简单,但可能。基本上,您会收集服务器在 NAT 中打出的漏洞。
Even if you managed to guess which port AIR is going to use on your device, it is not going to be very helpful, since there is a reasonably high probability that your NAT will translate it to another value IF your AIR device has a private IP address.
This issue does not happen if your AIR server has a public IP address. Most often, you can configure the server's NAT/Router to forward traffic as is. A port scan from the WAN will quickly tell you which port is used.
If you want to 'hijack' an outbound connection created by AIR itself, then you might try to have it contact a special server peer you have implemented which will forward traffic from and to it. Not simple, but possible. Basically you would collect holes punched in the NAT by the server.