The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 7 of 7

Thread: Getting into multiplayer, but need help

  1. #1

    Getting into multiplayer, but need help

    Hi all!
    I've been working with Flash for a few years as a hobby, and recently have become interested in creating multiplayer games. I found a tutorial that introduced xmlSockets to me, and some sample Java code that would act as the socket server for the Flash.
    (the tutorial is here:

    I understand the code and all, and have it working, running the compiled java class through my command prompt, and opening the swf with the 'simple chat' in it. It tells me "Connection Established" when I open it.

    My problem is running it through my Apache server (which I run for personal development through 'localhost'). When I have the 'simpleServer' running on Java, and open the .swf through localhost/xmlSocket.swf, the connection fails.

    I am at a loss as to why this happens, and my findings on Google haven't really helped me at all. Can anyone help me?

  2. #2
    Are you sure it isn't a secruity exception? The tutorial is written a while ago and security especially around the sockets have increased. Try modifying the code to trace any exceptions you get.

    for more information.

  3. #3
    I looked into the security stuff, and made a policyfile right in the root directory (at localhost/policyfile.xml), containing this:

        <allow-access-from domain="localhost" to-ports="*" />
    I'm not sure if that's right, since I have little experience with internet security and the like...

    Also, I added the following line to the top of the code in my Flash file:
    But my problem persists

    As for tracing out any exceptions... what would I do to get that to happen? I'm kind of fuzzy on the whole try..catch idea.

  4. #4
    I currently hate Adobe. Y'Know why? Because its program seems to believe that my policy file is improperly formatted. I looked up how to make a log for the policyfiles, and currently have a policy file being loaded (by the name 'crossdomain.xml') into the swf, with the following in it:

    <?xml version="1.0" encoding="UTF-8"?>
        <site-control permitted-cross-domain-policies="all"/>
        <allow-access-from domain="*" />
        <allow-http-request-headers-from domain="*" headers="*"/>
    When I use the debugger flash to open localhost/xmlSocket.swf, the log for policyfiles gets the following entry:

    OK: Searching for <allow-access-from> in policy files to authorize data loading from resource at xmlsocket://localhost:9999 by requestor from http://localhost/xmlSocket.swf
    Warning: [strict] Ignoring policy file at xmlsocket://localhost:9999 due to incorrect syntax.  See to fix this problem.
    Error: SWF from http://localhost/xmlSocket.swf may not connect to a socket in its own domain without a policy file.  See to fix this problem.
    I've tried about thirty variations on the xml file, from simple to complex, going off what someone from another forum, and various search results have given me. Not a single one has worked and I am going f**king insane.

    I'd sell my soul to satan for the solution to this, if I believed in that sort of thing, but I don't. I just really want some help with this because in 2 days in 3 different forums, I've gotten TWO responses in all, and it's utterly depressing.

  5. #5
    I just use: <cross-domain-policy><allow-access-from domain=* to-ports=* /></cross-domain-policy>

    Why don't you just have your java server send the policy file. You'll get a string that requests it and you can send it then disconnect then it will reconnect and have the swf send like a "connected" string to signify that it doesn't need one. That's kind of what I do.

  6. #6
    Thanks for the suggestion- I sort of tried to serve the file through java, but doesn't that seem kind of roundabout?
    (Also, I tried the simple/small xml contents, but it still gave me the bad syntax error.)

  7. #7
    Sirisian- I've changed my mind- that's exactly what I should have been doing!
    My searches turned up a new site, and this one had an example of a Java-based Policy Server.

    By running that and my own message relay server concurrently, and in my flash, sending a policy request, then trying to connect to the Policy Server, then connecting to the Relay server afterwards, the policy file is accepted, and a connection is made to my port 9999 server!

    So pretty much, that's what you told me to do- I guess I had been going about it the wrong way.

    Turns out that my port 9999 server was sending data that got interpreted as a policy file (even though it was supposed to be a welcome-to-chat message), and then not making a connection because the “policy file” was ignored! Fancy that.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012