2

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!

jocull
  • 20,008
  • 22
  • 105
  • 149

1 Answers1

0

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.

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
  • Thanks for the information. I decided to solve this problem with a Java applet instead, at least for now. I couldn't seem to get enough power out of the AIR app for NAT traversal. – jocull Apr 14 '11 at 05:29
  • It makes sense. Usually, when you don't have access to source code and if the source does not handle NAT traversal, it often a hopeless/very complicated situation. – Jérôme Verstrynge Apr 14 '11 at 10:16