XMLSocket on OS X

Hi,
I'm building a flash app that uses XMLSocket to talk to
another app on the same machine on port 9090. It works on windows
just fine, either in IE or in a projector. However, on Mac OS X it
only works in a stand-alone projector. It will NOT connect when
opened in either Safari or Firefox. In fact, my onConnect handler
never gets called when run that way. Is this a sandbox issue? Do I
need to change some security settings?

Flash won't install while Safari is running. The usual process is to download the flash installation disk image, mount it, run the installer (which will ask you to quit Safari), and then re-launch Safari when done.
If you don't already have the flash installation disk image in "Downloads",  you can get it at https://get.adobe.com/flashplayer. Quit Safari, mount the disk image and install. You should be good to go.

Similar Messages

  • How to get/process the Data from XMLSocket?

    Hello All,
    I'm using Adobe Professional CS6, and Actionscript 3.0.
    To start with I have a C# program that basically just feeds data out from a Server in the form of XML data. I then have a Flash program that should receive the data and then I'll do some stuff with it. We had this working in Actionscript 1.0 but we need to upgrade the code to Actionscript 3.0, but instead of just trying to convert stuff over to the new  Actionscript version, I'm going to re-write the program.
    So far I've basically just defined some EventListeners most of which I found examples of online for using XMLSockets. As of now the Flash program will connect an XMLSocket to the Server that is feeding out the data, and the server feeding the data resends new data every 5-10 seconds or so.
    So when a grouping of XML Data comes in on the port I defined, the following Function gets executed for handling the incoming data. For my EventListener's Function for "socket.addEventListener(DataEvent.DATA, dataHandler);"  ("socket" is defined as --> var socket = new XMLSocket(); ). So when the new data comes in it executes the above function.
    The trouble I'm having is declaring a new variable of type "XML" and then using that variable to pull out individual "nodes/children" from the incoming XML Data. I found an example online that was very close to what I want to do except instead of using an XMLSocket to get data constantly streaming in they use the "URLLoader" function to get the XML data. I know I'm receiving the XML data onto the server because if I set the (e: DataEvent) variable defined in the function "head" to a string and then run a trace on that I can see ALL of the XML data in the "Output Window".
    But I can't seem to be able to set (e: DataEvent) to a XML variable so I can access individual elements of the XML data. The example I found (which uses the URLLoader instead) uses this line (myXML = new XML(e.target.data);)  to set the XML Variable, which won't work for mine, and if I try to do the same thing in my code it simply prints this for as many lines as there is XML data --> "[object XMLSocket]"
    MY CODE:
    *I left out the other Functions that are in my code for the EventListeners you'll see defined below, except for the one in question:
                             ---> "function dataHandler(e: DataEvent):void"
    import flash.events.IOErrorEvent;
    import flash.events.ProgressEvent;
    import flash.events.SecurityErrorEvent;
    import flash.events.DataEvent;
    var socket = new XMLSocket();
    socket.addEventListener(Event.CONNECT, connectHandler);
    socket.addEventListener(Event.CLOSE, closeHandler);
    socket.addEventListener(DataEvent.DATA, dataHandler);
    socket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    socket.addEventListener(ProgressEvent.PROGRESS, progressHandler);
    socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
    var success = socket.connect('server.domain.name.local',3004);
    The code in this function was used from an example I found online as described above in the post: 
              LINK --> http://www.republicofcode.com/tutorials/flash/as3xml/
    // The Commented out code (*in blue) will show ALL the xml data inside the "Output Window":
    function dataHandler(e: DataEvent):void {
              // var myStr:String = e.data;
              var xml:XML;
              xml = new XML(e.target.data);  //<--- THIS DOESN"T WORK (I DONT THINK 'target' IS CORRECT HERE)??
              if (socket.connected)
                        // trace(myStr)
                        trace(xml);
    The Output from the line "trace(xml)" will show this data below in the "Output Window" (*FYI There should be 6 lines of XML Data on each 'update'):
    [object XMLSocket]
    [object XMLSocket]
    [object XMLSocket]
    [object XMLSocket]
    [object XMLSocket]
    [object XMLSocket]
    Could someone show or point me in the right direction on this. I want to be able to access specific parts of the incoming XML Data.
    Here's some sample XML Data:
    <MESSAGE VAR="screen2Display" TEXT="CSQ_1" />
    <MESSAGE VAR="F1_agentsReady" TEXT="111" />
    <MESSAGE VAR="F1_unavailableAgents" TEXT="222" />
    <MESSAGE VAR="F1_talkingAgents" TEXT="333" />
    <MESSAGE VAR="F1_callsHandled" TEXT="444" />
    <MESSAGE VAR="F1_ABDRate" TEXT="555" />
    Any thoughts or suggestions would be greatly appreciated..!
    FYI:
    I'm VERY new to Actionscript/Flash Developing (*about a week now), so go easy on me haha...
    Thanks in Advance,
    Matt

    Hey Guys, thanks ALOT for the replies!!
    Andrei1 and Sinious,
    The code I show above is actually just what I found in an example online, and its what i was trying to show you what "they" used
    in the URLLoader example. I wasn't trying to use URLLoader, but it was the closest example I found online to  what I was trying to
    do in terms of processing the XML Data, and not how I read it in. So XMLSocket IS definetly what I'm trying to use because the Server
    I'm receiving the XML Data from "pushes" it out every 10 seconds or so. So yea I definatly want to use XMLSocket and not URLLoader...
    Sorry for the confusion...
    The example you show:
         var xml:XML = new XML(e.data)
    Is actually what I had in my original code but I couldn't get it to show anything in the "Output Window" using the trace() method on
    it, so I assumed I wasn't doing it correctly...
    What my original code was in the "dataHandler()" Function was this:
    function dataHandler(e: DataEvent): void
        var xml: XML = XML(e.data);
        if (socket.connected)
            trace(xml);
            msgArea.htmlText += "*socket.connected = TRUE\n"
        } else {
            msgArea.htmlText += "*socket.connected = FALSE\n"
    OUTPUT:
    And what I get when I run a Debug on it is, in the "msgArea", which is just a simple Text Box w/ Dynamic Text on the main frame it prints:
        "socket.connected = TRUE
         socket.connected = TRUE
         socket.connected = TRUE
         socket.connected = TRUE
         socket.connected = TRUE
         socket.connected = TRUE"
    It prints that message 6 times in the msgArea for each XML Message that comes in (*which I think 6 times because there
    are 6 "sections/nodes" in the XML Data). But then NOTHING prints in the "Output Window" for the "trace(xml)" command.
    Not sure why nothing is showing in the "Output Window", maybe the XML is not complete? But I could see data in the "Output
    Window" when I set "e.data" to a string variable, so I know the Data is reaching the program. Since I could see the XML Data in
    a string variable, does that mean I can rule out that the XML Data coming in is considered a "complete" XML Document?
    Because I wasn't sure if to be considered a complete XML Document it would need to have this included in the message..?
                        "<?xml version="1.0"?>"
    For the tests I'm running, one single XML message which is being pushed out from the server looks like this:
    <MESSAGE VAR="screen2Display" TEXT="Call_Queue_1" />
    <MESSAGE VAR="F1_agentsReady" TEXT="111" />
    <MESSAGE VAR="F1_unavailableAgents" TEXT="222" />
    <MESSAGE VAR="F1_talkingAgents" TEXT="333" />
    <MESSAGE VAR="F1_callsHandled" TEXT="444" />
    <MESSAGE VAR="F1_ABDRate" TEXT="555" />
    Would I need to include that "Header" in the XML message above?
                   i.e. "<?xml version="1.0"?>"
    Or do I need to be more specific in the trace command instead of just using "trace(xml)"?
    Also yes, I already have a Flash Policy file setup and working correctly.
    Anyway, thanks again guys for the replies, very much appreciated!!
    Thanks Again,
    Matt

  • XMLSocket "Failed to load policy file" error

    I am trying to use an XMLSocket.swf file, and it is not connecting.  Do I need to open up a port on my server?  I am trying to run this on a dedicated remote Windows 2008 server.
    Here is the error from FlashFirebug:
         OK: Root-level SWF loaded: file:///C|/Users/vcaadmin/AppData/Roaming/Mozilla/Firefox/Profiles/70vbx4ys.default/exten sions/flashfirebug%40o%2Dminds.com/chrome/content/flashfirebug.swf
        OK: Root-level SWF loaded: http://speak-tome.com/flash/XMLSocket.swf
        OK: Searching for <allow-access-from> in policy files to authorize data loading from resource at xmlsocket://speak-tome.com:9997 by requestor from http://speak-tome.com/flash/XMLSocket.swf
        Error: Failed to load policy file from xmlsocket://speak-tome.com:9997
        Error: Request for resource at xmlsocket://speak-tome.com:9997 by requestor from http://speak-tome.com/flash/XMLSocket.swf has failed because the server cannot be reached.
    My crossdomain.xml is saved to the root of the web directory and looks like:
        <?xml version="1.0"?>
        <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
        <cross-domain-policy>
        <site-control permitted-cross-domain-policies="master-only"/>
        <allow-access-from domain="*"/>
        <allow-http-request-headers-from domain="*" headers="SOAPAction"/>
        </cross-domain-policy>
    I notice that both ports 843 and 9997 are closed for my domain (speak-tome.com - 72.167.253.16) when I check using a service such as yougetsignal.com/tools/open-ports.  Do I need to get these ports open to get the policy file to work?

    As a test, I uploaded my Flash/Gaia site into an existing site on my old host.  And although the site actually works in this setting, when I run things in the FlashPlayerDebugger, I'm still getting Security Sandbox Violations - so (as adninjastrator suggested in earlier post), this may have nothing to do with the DNS changes - but perhaps with my setting things up wrong somewhere so that the Flashplayer is trying to access my local computer - maybe??
    Debugger logs gives me this:
    Error: Failed to load policy file from xmlsocket://127.0.0.1:5800
    Error: Request for resource at xmlsocket://127.0.0.1:5800 by requestor from http://recreationofthegods.com/bin/main.swf has failed because the server cannot be reached.
    *** Security Sandbox Violation ***
    So, I've now uploaded the identical bin (which contains all the files for my site) - but I'm getting different behaviors on the two hosts.
    On the new holistic servers, the site won't go past the first page:  www.yourgods.com
    On the 1&1 servers, I still get runtime errors in FlashPlayerDebugger - but the site runs ok - http://www.RecreationOfTheGods.com/bin/index.html
    Posting those links in hopes someone with more experience in these sandbox issues can help steer me in the right direction.

  • XMLSocket.onConnect - success is false?

    I'm using Flash MX 2004 and i've written a sample socket
    server in php. it responds when i telnet in from everywhere:
    * using telnet from the Win XP command line from my desktop
    * using raw telnet from puTTY from my desktop
    * using telnet from the linux command line on the server
    flash, however won't let me connect with and XMLSocket.
    XMLSocket.connect returns true but my onConnect function always
    receives success=false. I CANNOT FIGURE OUT WHY. How do i figure
    out what the problem is?
    Here's my actionscript:
    var host:String = 'mydomain.com';
    var port:Number = 1234;
    mySock = new XMLSocket();
    mySock.onConnect = function(success) {
    trace('this is my anonymous onConnect function');
    trace(' success:' + success);
    mySock.send('foobar is what i sent');
    trace('here we go, connecting to ' + host + ":" + port);
    var foo = mySock.connect(host, port);
    trace('connect attempted, foo is ' + foo);
    mySock.close();
    the trace results are this:
    ===trace===
    here we go, connecting to mydomain.com:1234
    connect attempted, foo is true
    this is my anonymous onConnect function
    success:false
    ===trace===
    How on earth do I figure out what this false results is for?
    I have put the following crossdomain.xml file at the root of
    mydomain.com:
    ===crossdomain.xml===
    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM
    http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <!-- Policy file for
    http://www.mysite.com -->
    <cross-domain-policy>
    <allow-access-from domain="*" />
    </cross-domain-policy>
    ===/crossdomain.xml===
    I have also tried uninstalling flash player 9 and installing
    he debug version instead. the trace statements end up in
    flashlog.txt but this directive is totally ignored apparently:
    SecurityDialogReportingEnable = true
    I never get any security message or anything. I'm totally
    mystified.

    ALRIGHTY THEN. Thanks so much to all of your for helping so
    much.
    Given the resounding silence at this very very simple
    request, I suppose I must resort to a packet sniffer. I'll report
    back when I know more.

  • Probelm receive xml with XMLSocket

    Hi! I'm doing a socket program which will send and receive
    data from a server. The server runs perfectly fine with other
    socket client (vb, java etc).
    But I have problem receive data using XMLSocket in Flash. It
    send successfully, skip the receiving data and then finally go to
    "history" frame.
    Please see the attached code for more information. Thank you
    very much!!

    hi,
    What i understand from your scenario is XI> BC> SAP system.
    1)XI-->BC
    U need to configure XI's-BCAdapeter(as receiver).
    in URL specify teh follwoing :
    http://<hostname>:5555/invoke/folder1.folder2./<service-to-be invoked>
    together with the username and password.
    2) BC--> SAP
    To invoke an IDoc, go to Routing rules and specify the sender, receiver, and the Message Type(IDoc name). In the next page, specify the name of the flow service to be created. and the Flowservice to be invoked whenever a message comes in.
    Hope this gives you some input.
    Regards,
    Siva Maranani

  • XMLSocket connection fails

    Hello everyone ,
    My actionscript2 is used for xmlsocket connection .
    The xmlsocket connection failed when the crossdomain.xml file size more than 20k.
    Does anyone has idea or solution ?
    Thanks .

    The first thing to do, is that you check they are both fully updated to the latest update. For example, if one is on iOS 7 and the other IOS 8, that may be the cause of the problem. If then you still cant connect, there may be a problem with one of the iPads. Try facetimeing another iPad user, preferable an ipad mini, and see if the problem persists.

  • Something is wrong with XMLsocket

    alright , I am using XMLsocket class, actrionscript 2.0
    (flash 8). I have set up appache server on port 1024, and I can
    connect without problems. But something's wrong with sending test
    data (I am using log file to check for incoming server requests)
    the code is this:
    quote:
    var theSocket:XMLSocket = new XMLSocket();
    theSocket.connect("localhost", 1024);
    theSocket.onConnect = function(myStatus) {
    if (myStatus) {
    TraceTxt("connection successful");
    } else {
    TraceTxt("no connection made");
    theSocket.onClose = function () {
    trace("Connection to server lost.");
    function sendData() {
    var myXML:XML = new XML();
    var mySend = myXML.createElement("thenode");
    mySend.attributes.myData = "someData";
    myXML.appendChild(mySend);
    theSocket.send(myXML);
    TraceTxt("I am trying to send: " + myXML);
    sendButton.onRelease = function() {
    sendData();
    theSocket.onData = function(msg:String):Void {
    trace(msg);
    function TraceTxt(strMessage:String)
    dtxMessage.text = dtxMessage.text + strMessage + "\n";

    Hello Alana,
    Do these songs/tracks sound okay in iTunes?  Have you tried resetting your iPod to see if that makes a difference?  To do this, press and hold both the Select (Center) and Menu buttons together until the Apple logo appears. 
    I would also try a different set of headphones/earbuds to see if that makes a difference as well.
    And if the problem still continues, try restoring your iPod via iTunes and reloading all your music back over to it.
    The last you may want to consider doing, if nothing from above resolves the issue is to rerip these tracks into iTunes.  Try importing them in a different format or at a different bit rate to see if that makes a difference.
    B-rock

  • Help! Flash MX to Labview with XMLsocket problem

    I'm attempting to send strings to Labview using the XMLsocket object
    in Macromedia Flash MX. I created a layer in Flash with the following
    Action script:
    mySocket = new XMLsocket();
    mySocket.connect("localhost",2055);
    Then I created a layer with a button that has the following button
    Action script:
    on (release) {
    mySocket.send("mystring");
    Then I created a Labview program (on the same machine) that has a
    single while loop with code that creates a listener at port 2055 (the
    port connected to Flash) and some code for reading the port.
    This setup works, except Labview will only receive the string once
    from the button push, even though the receive code is in a loop.
    Subsequent button pushes in Flash does not resul
    t in characters being
    received in LV. Has anyone here done this before? Thanks.
    gm

    Fixed it. You've got to have the Labview create listener VI started
    first and also outside the while loop. Works great!
    [email protected] (greenman) wrote in message news:<[email protected]>...
    > I'm attempting to send strings to Labview using the XMLsocket object
    > in Macromedia Flash MX. I created a layer in Flash with the following
    > Action script:
    >
    > mySocket = new XMLsocket();
    > mySocket.connect("localhost",2055);
    >
    > Then I created a layer with a button that has the following button
    > Action script:
    >
    > on (release) {
    > mySocket.send("mystring");
    > }
    >
    >
    > Then I created a Labview program (on the same machine) that has a
    > single while loop with code that creates a listener at port 2055 (the
    > port connected to
    Flash) and some code for reading the port.
    >
    > This setup works, except Labview will only receive the string once
    > from the button push, even though the receive code is in a loop.
    > Subsequent button pushes in Flash does not result in characters being
    > received in LV. Has anyone here done this before? Thanks.
    >
    > gm

  • About XMLSocket reconnection

    hello: I got a question about XMLSocket. The problem is this:
    if the connection is established to the server then it is done. if
    the connection is not successfully established then it will retry
    the connection 10 seconds later.
    here is my code:
    class .... {
    public function Connect():Void {
    var _isConnected:Boolean = _conn.connect(_hostIP,
    _hostPort);
    _conn.onConnect = function(_isConnected:Boolean):Void {
    if (_isConnected) {
    _conn.send("Hello there.");
    // MessageModule();
    } else {
    trace("No connection.");
    // Wait(); ???
    // Reconnect(); ???
    in my code I try to send "Hello there if it succeeds" while I
    still can't figure out how can I implement the //Wait() and
    //reconnect part. please give me some help. Thanks!!!!!

    crossdomain.xml:
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
    <!--- 
    this should be in the root and allows all policy files but gives access to no domains.
    a policy file (eg, crossdomain2.xml) in a subdirectory with allow-access-from allows domain access to
    the directory, and dependent subdirectories, that contain crossdomain2.xml
    -->
    <cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    </cross-domain-policy>
    crossdomain2.xml:
    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <!--- 
    this policy file (eg, crossdomain2.xml) is in a directory it will allow access to that directory and its subdirectories
    IF there's a root policy file  (eg, crossdomain.xml) allowing cross-domain-policies
    -->
    <cross-domain-policy>
    <allow-access-from domain="www.kglad.com" />
    </cross-domain-policy>

  • XmlSocket.onXML and xmlSocket.onData problem

    Hi,
    I am having a problem with reading information that is being passed from a C# server. When I use xmlSocket.onXML, the xml object being passed from the server does not have any elements at all. When I use xmlSockt.onData, I am able to get the following output with tace:
    <?xml version="1.0"?>
    <Packet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <UserID>5555</UserID>
      <UserName>Success</UserName>
      <Operation>RefreshUsers</Operation>
    </Packet>
    However, when I check the string variable that I used to store this string in debug mode, the value of the string is "". And when I try to create an XML object using var my_xml:XML = new XML(srcstring); I get the same problem as when I used the xmlSocket.onXML method. The xml object my_xml contains no elements at all.
    Can anyone help me out on this? Thank you.

    So I switched from XMLSocket to just plain Socket.
    I have this now:
      var sock:Socket = new Socket();
                sock.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
                sock.connect("localhost", 7778);
                sock.writeUTFBytes(xmlMsg);
                sock.flush();
    But nothing gets transmitted unless I close the Flex app.
    I don't get this. What seems to be a problem?
    I read an API docs twice and it says that writeUTFBytes (or any other write methods) are just putting stuff in a buffer
    the flush() is the one that signals that the buffer content needs to be sent.
    I'm doing just that and still I get nothing on the other side unless I close the Flex app.
    Any suggestion?
    Thanks
    Greg

  • XMLSocket onData Issue

    I am trying to narrow down a bug in an application that
    utilizes the XMLSocket class. I have reduced it to the following
    code below. Is there such a scenario that practically simultaneous
    messages sent from a server would cause 'false' to be traced more
    than once (ie. can the code in the onData method evaluate test as
    false more than once because onData is called a second time before
    the first onData method has had time to update test to true)? Can
    the onData method be treated as atomic? To a certain degree....?
    At the root of this question, I am trying to grasp how
    asynchronous calls are handled/queued to make sure I understand
    them correctly and prevent certain cases where a single-time
    operation may occur twice. If any one can help or direct me to
    information regarding this, I would be very thankful.
    Dan

    Hi Tracy,
    Thanks for your reply.
    SocketComm is a action script class which maintains XMLSocket
    object for the whole application.
    package asclasses
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.XMLSocket;
    import mx.controls.Alert;
    public class SocketComm extends Sprite
    private var hostName:String = "localhost";
    private var port:uint = 8080;
    private var socket:XMLSocket;
    public function createSocketConnection(hostName:String,
    port:uint):XMLSocket {
    if(socket == null) {
    socket = new XMLSocket();
    socket.connect(hostName, port);
    }else if(socket != null && !socket.connected) {
    socket.connect(hostName, port);
    return socket;
    Actually now i am able to communicate with server over
    XMLSocket.
    There was some problem at server side.
    But still i am not comfortable with using
    SocketComm(XMLSocket) as a common utility class due to event based
    asynchronus model. Like in Java Socket all calls are synchronus, I
    can easily create common class for socket communication.
    But due to my unfamiliarity with event based asynchrous model
    of programming, I am facing difficulties.
    Like my requirement is to use SocketComm class as a
    communication medium with server for various business operations
    like add, modify and delete etc. from various Flex UI screens. But
    due to event based model, I am not really sure how and when socket
    is going to send response.
    So if you look at my first post, I have added all listeners
    to mxml page but i feel this is not a good design, As i have
    atleast 4-5 mxml pages where in I will repeat these listeners.
    I would really appreciate if you could provide me some
    guidance on using SocketComm class as a effective common class.
    Thanks in advance :)
    Regards
    Tarun

  • XMLSocket Issue

    HI,
    I have written a small program which uses XMLSocket to
    communicate with some server.
    It works for the first time, I mean when i send first
    message, I got the response from server but after that flex client
    does not send any message to server and i see no exception in the
    code.
    can anybody pls. help ?
    Following is the code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" width="800" height="600">
    <mx:TraceTarget level="0" />
    <mx:Script>
    <![CDATA[
    import asclasses.SocketComm;
    import flash.system.Security;
    import asclasses.ACTURLLoader;
    import mx.controls.Alert;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.http.HTTPService;
    private var response:String;
    private var socketComm:SocketComm;
    private var sock:XMLSocket;
    private var isSocketConnected:Boolean = false;
    private function handleTest():void {
    // Printing Sandbox
    var sandbox:String = Security.sandboxType;
    sandboxType.text = sandbox;
    if(!isSocketConnected) {
    // Local Windows Service
    var host:String = winServiceHost.text;
    var port:String = winServicePort.text;
    socketComm = new SocketComm();
    sock = socketComm.createSocketConnection(host, int(port));
    configureSocketListeners(sock);
    }else {
    Alert.show("Entered in else part");
    if(sock.connected) {
    Alert.show("socket is connected");
    try {
    sock.send(msg.text+"\n");
    }catch(ie:IOError) {
    Alert.show(ie.toString());
    }else {
    Alert.show("sock is not conected");
    private function
    configureSocketListeners(dispatcher:IEventDispatcher):void {
    dispatcher.addEventListener(Event.CLOSE, socketHandler);
    dispatcher.addEventListener(Event.CONNECT, socketHandler);
    dispatcher.addEventListener(DataEvent.DATA, socketHandler);
    dispatcher.addEventListener(ErrorEvent.ERROR,
    socketHandler);
    dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
    socketHandler);
    dispatcher.addEventListener(IOErrorEvent.IO_ERROR,
    socketHandler);
    dispatcher.addEventListener(ProgressEvent.SOCKET_DATA,
    socketHandler);
    private function socketHandler(event:Event):void {
    var socket:XMLSocket = XMLSocket(event.target);
    Alert.show(event.toString());
    trace(event.toString());
    if(event.type == Event.CLOSE) {
    winServiceContent.text = response;
    }else if(event.type == SecurityErrorEvent.SECURITY_ERROR) {
    socket.close();
    }else if(event.type == IOErrorEvent.IO_ERROR) {
    socket.close();
    }else if(event.type == DataEvent.DATA) {
    winServiceContent.text += DataEvent(event).data;
    }else if(event.type == Event.CONNECT) {
    // Sending first msg
    Alert.show("Sending Message : " + msg.text);
    socket.send(msg.text+"\n");
    isSocketConnected = true;
    }else if(event.type == ProgressEvent.SOCKET_DATA) {
    trace("progressHandler loaded:" +
    ProgressEvent(event).bytesLoaded + " total: " +
    ProgressEvent(event).bytesTotal);
    ]]>
    </mx:Script>
    <mx:Form id="fff" x="36" y="10" width="500"
    height="414">
    <mx:FormHeading label="Security Test Form"/>
    <mx:FormItem label="Sandbox Type">
    <mx:Text id="sandboxType"/>
    </mx:FormItem>
    <mx:FormItem label="Windows Service Host">
    <mx:TextInput id="winServiceHost"
    text="10.201.205.196"/>
    </mx:FormItem>
    <mx:FormItem label="Windows Service Port">
    <mx:TextInput id="winServicePort" text="8081"/>
    </mx:FormItem>
    <mx:FormItem label="Command Message">
    <mx:TextInput id="msg" />
    </mx:FormItem>
    <mx:FormItem label="Windows Service Content">
    <mx:TextArea id="winServiceContent"/>
    </mx:FormItem>
    </mx:Form>
    <mx:Button label="Test" click="handleTest()" x="54"
    y="452"/>
    <mx:Button label="Clear" x="132" y="452" />
    </mx:Application>

    Hi Tracy,
    Thanks for your reply.
    SocketComm is a action script class which maintains XMLSocket
    object for the whole application.
    package asclasses
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.XMLSocket;
    import mx.controls.Alert;
    public class SocketComm extends Sprite
    private var hostName:String = "localhost";
    private var port:uint = 8080;
    private var socket:XMLSocket;
    public function createSocketConnection(hostName:String,
    port:uint):XMLSocket {
    if(socket == null) {
    socket = new XMLSocket();
    socket.connect(hostName, port);
    }else if(socket != null && !socket.connected) {
    socket.connect(hostName, port);
    return socket;
    Actually now i am able to communicate with server over
    XMLSocket.
    There was some problem at server side.
    But still i am not comfortable with using
    SocketComm(XMLSocket) as a common utility class due to event based
    asynchronus model. Like in Java Socket all calls are synchronus, I
    can easily create common class for socket communication.
    But due to my unfamiliarity with event based asynchrous model
    of programming, I am facing difficulties.
    Like my requirement is to use SocketComm class as a
    communication medium with server for various business operations
    like add, modify and delete etc. from various Flex UI screens. But
    due to event based model, I am not really sure how and when socket
    is going to send response.
    So if you look at my first post, I have added all listeners
    to mxml page but i feel this is not a good design, As i have
    atleast 4-5 mxml pages where in I will repeat these listeners.
    I would really appreciate if you could provide me some
    guidance on using SocketComm class as a effective common class.
    Thanks in advance :)
    Regards
    Tarun

  • XMLSocket Class

    My Flex Application is using XMLSocketClass for communicating
    with Webserver. But connection cannot be established. I am not
    getting any error message.
    I am using the follwing code for establishing the connection:
    =================================================================
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.collections.ArrayCollection;
    import flash.net.Socket;
    private var socket:XMLSocket;
    private function connectToServer():void
    socket = new flash.net.XMLSocket();
    socket.connect("71.222.34.91", 8002);
    function sendData()
    var xmlvalue:String=txtData.text.toString()
    var
    xmlfile:String="<command>GetRevision</command>"
    socket.send(xmlfile);
    private function getData()
    socket.addEventListener(DataEvent.DATA, onData);
    private function onData(event:DataEvent):void {
    trace("[" + event.type + "] " + event.data);
    ]]>
    </mx:Script>
    <mx:HBox width="80%" horizontalAlign="center">
    <mx:TextInput id="txtData" name=""/>
    <mx:Button id="btnConnect" label="Connect"
    click="connectToServer();btnConnect.enabled = false"/>
    <mx:Button id="btnSend" label="Send Data"
    click="sendData()"/>
    <mx:Button label="getData" id="btnGet"
    click="getData()"/>
    </mx:HBox>
    </mx:Application>
    ====================================================================
    Please help me to handle this error.

    Oops! We forgot to sent the server app's EOL and EOF byte
    stream. Without them the server app was simply caching the data
    until such a byte stream was received.

  • XMLSocket Problem

    I can work fine which run in flash . I can see the connection can established and disconnected until i close the flash
    but i publish the flash to html and run in broswer, the flash can connect to server but it will disconnected in the same time. That means i can see the log is established connection then disconnect connnection.
    I cannot find the solution.
    Please help.
    Thank you
    flash code :
    mySocket = new XMLSocket();
    mySocket.onConnect = function(success) {
        if (success) {
            msgArea.htmlText += "<b>Server connection established!</b>";
        } else {
            msgArea.htmlText += "<b>Server connection failed!</b>";
    mySocket.onClose = function() {
        msgArea.htmlText += "<b>Server connection lost</b>";
    XMLSocket.prototype.onData = function(msg) {
        msgArea.htmlText += msg;
    mySocket.connect("dyn.obi-graphics.com", 9999);
    //--- Handle button click --------------------------------------
    function msgGO() {
        if (inputMsg.htmlText != "") {
            mySocket.send(inputMsg.htmlText+"\n");
            inputMsg.htmlText = "";
    pushMsg.onRelease = function() {
        msgGO();

    So I switched from XMLSocket to just plain Socket.
    I have this now:
      var sock:Socket = new Socket();
                sock.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
                sock.connect("localhost", 7778);
                sock.writeUTFBytes(xmlMsg);
                sock.flush();
    But nothing gets transmitted unless I close the Flex app.
    I don't get this. What seems to be a problem?
    I read an API docs twice and it says that writeUTFBytes (or any other write methods) are just putting stuff in a buffer
    the flush() is the one that signals that the buffer content needs to be sent.
    I'm doing just that and still I get nothing on the other side unless I close the Flex app.
    Any suggestion?
    Thanks
    Greg

  • XMLSocket to localhost problem

    Hello!
    Doe anyone have experience with XMLSockets that have to connect to the localhost (or 127.0.0.1)?
    My flash application can connect to all other servers but not to the server the flash app resides on.
    The server accepts the socket but in flash the onConnect event has "false" as parameter. If I ignore this and start sending anyway, sometimes the data is send to the server.
    I run windows CE6.0 R3 with flash lite 3.1.
    Any Idea's?
    Thanks,
    John.

    Hi,
    don't know if it helps still, but i am using XMLSocket on Symbian: my FlashLite code accesses an natice C++ http server, using XMLSOckets.
    It works quite well, however i had some small tunings to do:
    * XML form (the one which is sent over to the server) has to terminate by '\0'. My code is adding an addtioanla '\0\ at the end, both on the FL code and on the server code
    * Of course, you have to publish your FL as "netwrok access"
    * .... and also to solve all the security problems (i.e. either crossdomain, or using Trusted subdir).
    Voila, not sure how much of ti applies to your plateform !
    Jacques.

Maybe you are looking for

  • How can I stop my iPhone from randomly, persistently, making a noise it should not be making?

    This has been happening for about 1-2 months. My iPhone makes a sound which is a normal iOS sound, but without any reason for it to be making the sound. It happens randomly, perhaps 1 day per week although when it happens it happens several times in

  • PO Document Type Without Good Reciept and Invoice Reciept

    Hi All, Can i configure my document type in such a way that it do not require Goods Receipt as well as Invoice Verification. I know i can do the same with Account assignment category. But what if i am not using any particular account assignment categ

  • Insert into temporary table

    I migrate procedures MS SQL Server to Oracle. In MS SQL SSERVER the use of instructions INSERT with procedure results which are in storage or dynamic instructions EXECUTE in place of VALUES clause is permissible. This construction is similar to INSER

  • Bug: Diff fails for multiple constraints on one column.

    Hi all, I think, I came across a bug in SQL Developer: SQL Developer version: 3.0.04 create table USER_A.foo (val NUMBER not null, CHECK (val IN (1,2,3))); create table USER_B.foo (val NUMBER not null); Comparing these two schemas does not give any d

  • Midi export sounds like a bunch of pianos...

    So I'm trying to export a project I made as a MIDI to share with my friend, and every part (guitars, drums, bass) has been exported with the instrument set to the piano. How do I get Logic to export a Midi file sans piano? (P.S., This is Logic Expres