explorer
08-17-2001, 02:58 PM
I am trying to establish TWO simultaneous XMLSockets
to servers listening at 2 different ports (same domain as Flash swf), however, this does NOT work. Connection with one socket / port works perfectly. However, in the case of connection to multiple sockets, only the LAST connection is successfull. In my example below, first connection fails silently (no errors given), even though it works fine when there is no second connection attempt!
Why? Am I missing something (like the second socket must be in different frame, swf or so), or this is a Flash bug?! Thanks a lot in advance! Here is my code:
//First connection, works for itself, fails with 2nd one
loginSocket1 = new XMLSocket();
loginSocket1.onConnect = myOnConnect1;
loginSocket1.onXML = myOnXML1;
myServer1="localhost";
myPort1="8080";
myMessage1="Msg to First Server";
trace("1st Server is:"+myServer1+", my Port1 is:"+myPort1);
loginSocket1.connect(myServer1.toString(), myPort1.toString());
loginSocket1.send(myMessage1);
//Second connection, takes over when 2 connections are tried
loginSocket2 = new XMLSocket();
loginSocket2.onConnect = myOnConnect2;
loginSocket2.onXML = myOnXML2;
myServer2="localhost";
myPort2="8282";
myMessage2="Msg to Second Server";
trace("2nd Server is:"+myServer2+", my Port2 is:"+myPort2);
loginSocket2.connect(myServer2, myPort2);
loginSocket2.send(myMessage2);
to servers listening at 2 different ports (same domain as Flash swf), however, this does NOT work. Connection with one socket / port works perfectly. However, in the case of connection to multiple sockets, only the LAST connection is successfull. In my example below, first connection fails silently (no errors given), even though it works fine when there is no second connection attempt!
Why? Am I missing something (like the second socket must be in different frame, swf or so), or this is a Flash bug?! Thanks a lot in advance! Here is my code:
//First connection, works for itself, fails with 2nd one
loginSocket1 = new XMLSocket();
loginSocket1.onConnect = myOnConnect1;
loginSocket1.onXML = myOnXML1;
myServer1="localhost";
myPort1="8080";
myMessage1="Msg to First Server";
trace("1st Server is:"+myServer1+", my Port1 is:"+myPort1);
loginSocket1.connect(myServer1.toString(), myPort1.toString());
loginSocket1.send(myMessage1);
//Second connection, takes over when 2 connections are tried
loginSocket2 = new XMLSocket();
loginSocket2.onConnect = myOnConnect2;
loginSocket2.onXML = myOnXML2;
myServer2="localhost";
myPort2="8282";
myMessage2="Msg to Second Server";
trace("2nd Server is:"+myServer2+", my Port2 is:"+myPort2);
loginSocket2.connect(myServer2, myPort2);
loginSocket2.send(myMessage2);