Adobe AIR, URLRequest, and local ports

939 views Asked by At

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!

1

There are 1 answers

2
Jérôme Verstrynge On BEST ANSWER

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.