A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: XMLSocket Setup

  1. #1
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404

    XMLSocket Setup

    Hi, im attempting everything I can to setup a socket connection but it just wont connect directly on my site, but the socket will establish a connection from the ide this is the flash script I am testing:

    PHP Code:
    // Create XMLSocket object
    Security.loadPolicyFile("crossdomain.xml");
    var 
    theSocket:XMLSocket = new XMLSocket();
    // Connect to a site on unused port above 1024 using connect() method.
    // Enter localhost or 127.0.0.1 for local testing.
    // For live server, enter your domain www.yourdomain.com
    theSocket.connect('127.0.0.1'80);
    // displays text regarding connection
    theSocket.onConnect = function(myStatus) {
        if (
    myStatus) {
            
    conn_txt.text "success";
        } else {
            
    conn_txt.text "no connection made";
        }
    };
    // data to send
    function sendData() {
        var 
    myXML:XML = new XML();
        var 
    mySend myXML.createElement("thenode");
        
    mySend.attributes.myData "someData";
        
    myXML.appendChild(mySend);
        
    theSocket.send(myXML);
    }
    // button sends data
    btn.onRelease = function() {
        
    sendData();
    };
    // traces data returned from socket connection
    theSocket.onData = function(msg:String):Void {
        
    trace(msg);
    }; 
    also, I included a crossdomain.xml at the root of my site as follows:
    PHP Code:
    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
    <!-- Policy file for xmlsocket://socks.example.com -->
    <cross-domain-policy>
       <!-- This is a master-policy file -->
       <site-control permitted-cross-domain-policies="master-only"/>
       <!-- Instead of setting to-ports="*",
    administrators can use ranges and commas -->
       <!-- This will allow access to ports 123, 456, 457, and 458 -->
       <allow-access-from domain="*" to-ports="*" />
    </cross-domain-policy>
    I will also add updates to this thread if I get any further but I really need someone to help establish a simple connection and ill worry about the php/java serving with the 0x00

  2. #2
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    update: so I made a boolean to show if System.security.loadPolicyFile("http://www.indocastles.com/crossdomain.xml"); gets the policy file, and it returns true, but the xmlsocket returns false :/

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    This might give you a little more understanding, http://www.lightsphere.com/dev/artic...et_policy.html

  4. #4
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    i get this in my shell response, hmmm

    bind: Permission denied at ./socketpolicy.pl line 50.
    Last edited by AS3.0; 06-10-2015 at 04:33 PM.

  5. #5
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    ok, got it running it created a log file which says: starting socket on port 483. but my flash file still seems to not connect.

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    HI,

    OK , you are getting closer.

    How did you execute the perl script on your server and what is the code you use to communicate.

    All files and code if you need to go further.

  7. #7
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hi, with the link you provided, i created the socketpolicy.pl in the root with pico, i then run the command "chmod +x socketpolicy.pl" so i can run it and last i i run the socketpolicy.pl script by typing this command "./socketpolicy.pl > /dev/null &" and it creates a log in my root which i than open and it reads..

    Starting server on port 843
    Server started. Waiting for connections.

    if you want to read the file just click view source at this link http://www.lightsphere.com/dev/artic...et_policy.html

    i also keep the file as is, with the $bindip commented as default and such
    Last edited by AS3.0; 06-11-2015 at 01:10 PM.

  8. #8
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    yes I've seen that page Alloy, I gave you the link,
    I just wonder how your fla works, as the same code here doesnt function too well, all it says is success, infact it doesn't even say that anymore.

    Ok it does say success, i turned wamp back on.

    I have a few socket flas set up here and your seems like it will never work.
    Last edited by fruitbeard; 06-11-2015 at 01:27 PM.

  9. #9
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    this is the fla script i upload compiled to swf exactly as it is ports and all

    PHP Code:
    // Create XMLSocket object
    var theSocket:XMLSocket = new XMLSocket();
    // Connect to a site on unused port above 1024 using connect() method.
    // Enter localhost or 127.0.0.1 for local testing.
    // For live server, enter your domain www.yourdomain.com


    theSocket.connect('localhost'80);
    // displays text regarding connection
    theSocket.onConnect = function(myStatus) {
        if (
    myStatus) {
            
    conn_txt.text "success";
        } else {
            
    conn_txt.text ="no connection made";
        }
    };
    // data to send
    function sendData() {
        var 
    myXML:XML = new XML();
        var 
    mySend myXML.createElement("thenode");
        
    mySend.attributes.myData "someData";
        
    myXML.appendChild(mySend);
        
    theSocket.send(myXML);
    }
    // button sends data
    btn.onRelease = function() {
        
    sendData();
    };
    // traces data returned from socket connection
    theSocket.onData = function(msg:String):Void {
        
    trace(msg);
    }; 
    let me try your socket script if possible

  10. #10
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    As3

  11. #11
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    from desktop again, it says:

    PHP Code:
    Connected
    [Event type="connect" bubbles=false cancelable=false eventPhase=2]
    HTTP/1.1 200 OK

    Date
    Thu11 Jun 2015 18:35:14 GMT

    Server
    Apache

    Transfer
    -Encodingchunked 
    from my site it says: http://indocastles.com/play/indocastles.html
    Last edited by AS3.0; 06-11-2015 at 02:35 PM.

  12. #12
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I see it, thats because you have no policy being sent to the flash file, look up the security event.

    Did you change local for site in the file.

    Anyway, you need to do this yourself, i just gave you a file to compare with your AS2 file
    Last edited by fruitbeard; 06-11-2015 at 02:58 PM.

  13. #13
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    http://indocastles.com/play/indocastles.html wait acouple seconds and itl output the text error #2048 clear ur cache if it shows a different swf
    Last edited by AS3.0; 06-11-2015 at 02:59 PM.

  14. #14
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    HI,

    Security Error
    [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"]

    is to do with the policy file not being sent to the flash file from the server

    this is where you need to send the policy using the perl file to flash

  15. #15
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I have the policy server running and your flash file up as is, :/

  16. #16
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    well before i go out, mess around , check the code, find out how to get the policy response

  17. #17
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    I dont think my file is set up to get the response you require.

    You're on your own now Alloy, or maybe some kind soul might step in and help you, I gave you the link.

  18. #18
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Alright.
    Year 99: "old man alloy" - The sockets almost up and running

  19. #19
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Thanks for all your help and support by the way, ill let you know when i get it

  20. #20
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    the policy server is running, you can try any method on my swf to connect and you will see that socket servers are a myth http://indocastles.com/play/indocastles.html

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center