Situation #1.
You want to use the builtin WWW class to fetch stuff from a HTTP server.
In this case, you MUST have a crossdomain.xml file that is hosted by that SAME HTTP server,
This will allow, and ONLY allow Unity's builtin WWW class to work. It has no effect on the usage of .NET sockets within Unity.
This particular setup will NEVER help you get .NET sockets (and by
extension UniWeb) working within Unity WebPlayer.
Situation #2.
You want to use UniWeb to fetch stuff from a HTTP server.
In this case, you MUST have a server process running on a port on the SAME host, which follows the behaviour specified in the manual.
This will allow .NET sockets (and therefore UniWeb) to work within a Unity WebPlayer. The Security.PrefetchSocketPolicy MUST be called before .NET sockets will successfully connect to a host on ANY port.
Particularly note this section from the manual:
Specifically the server expects to receive a zero-terminated string
that contains. It only sends to the client the socket policy xml document when this string (and exactly this string) has been received. Further, it is required that the xml header and xml body are sent with a single socket write.
Also note:
Note: Whilst the crossdomain.xml and socket policy files are both xml
documents and are broadly similar, the way that these documents are served are very different. Crossdomain.xml (which applied to http requests) is fetched using http on port 80, where-as the socket policy is fetched from port 843 using a trivial server that implements the <policy-file-request/>. You cannot use an http server to issue the socket policy file, nor set up a server that simply sends the socket policy file in response to a socket connection on port 843. Note also that each server you connect to requires its own socket policy server.
5 comments:
I don't understand. Can you please explain in smaller words. Thanks
LOL just for you Paul, I'll get my nephew to translate! ;-)
I've setup the socket policy server on port 1201 and I can successfully call Security.PrefetchSocketPolicy ("122.248.244.189", 1201, 50000) function to prefetch as I am using different port rather than 843.
After that, I am trying to call
http://122.248.244.189:80/0/6BpN0r59lu/sBvNlrZi6L?page=1&rand=3211824&limit=10 using UniWeb and it still returns System.Security.SecurityException: Unable to connect, as no valid crossdomain policy was found
error. Can you please point me my missing point?
Thanks alot
I would start by verifying that your security policy server is actually receiving a request when you call Security.Prefetch, then I would verify that your crossdomain.xml file is valid.
Yes, you can verify that the crossdomain.xml here
http://122.248.244.189/crossdomain.xml
and you can call Security.PrefetchSocketPolicy ("122.248.244.189", 1201, 50000) which returns true... which seems to me that the socket policy server is actually receivine a request.
Post a Comment