I'm surprised how many walls I've run into trying to solve this, fairly
simple problem.

Essentially, I need to perform RPC style communication with the server
hosting the .swf. The server, which is also under my control, communicates
custom binary data over HTTP, expecting HTTP POST requests from the client.
Part of its response includes custom headers to indicate the status of the
request, with the body containing the raw binary data needed.

Of course, neither the Flex HTTPService, URLLoader, or URLStream allow me to
parse custom response headers (not to mention setting some strange
restrictions on which headers I can transmit). Instead, I turned to Sockets
in the hopes of writing my own, more FLEXible HTTP client.

Alas, I cannot seem to use Sockets to open a connection to port 80 on the
host serving the .swf. From the following documentation:

http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001952.html#145389

I learn several things:

  - Socket communication requires a socket policy file, distinct from a
  document policy file
  - A socket policy file must be obtained using the same communication
  protocol as the socket (i.e. a socket opened on port 501 requires a
  socket policy file from port 501)
  - A socket policy file can be used to allow port access to ports <
  1024
  - A special syntax, 'xmlsocket://server:port/crossdomain.xml' can be
  used to request a socket policy file from a different port
  - Using loadPolicyFile and a standard document policy file, access to
  ports > 1024 are implicitly enabled, and any 'to-ports' settings in the
  configuration file are ignored.

Basically, at the end of the day, I want a .swf served from a host to be
able to open socket connection on port 80 back to the server that hosted it
to do HTTP operations. I cannot seem to be able to do this unless I:

  - Open another port < 1024 to serve a socket policy file
  - Modify the server to respond to the Flash request for a socket
  policy file ( http://www.blog.lessrain.com/?p=512 )


Why must it be so difficult to access the response headers from an HTTP
connection?! This isn't a crossdomain issue at all -- this is communication
with the very same host that served the .swf file in the first place.

Has anyone managed to overcome this issue cleanly?
Any input from more experienced Flex coders?

Any help would be greatly appreciated :)

Reference post, that yielded inconclusive results:
http://tech.groups.yahoo.com/group/flexcoders/message/71730

--
Jesse Hallam
University of Waterloo Junior

"For scarcely for a righteous man will one die: yet peradventure for a good
man some would even dare to die. But God commendeth his love toward us, in
that, *while we were yet sinners*, Christ died for us. " (Romans 5:7, 8)

Reply via email to