0 Replies Latest reply on Mar 12, 2010 5:10 PM by Carlillus6

    Coordinating a Client (Flash AS2) and a Server (C#) using Sockets


      Hi, since a few days ago, I'm interested in learn how sockets work in diferent languages because I'd like to create an online application, starting, in example, with a minichat or something similar.


      Since now, I've created a server in C#, which is that should control the Minichat and all the connections; and another application with Flash CS4 in ActionScript 2, which will be the client that will use all other users to speak.

      Well, I have reached to send packets to the server and do that the server returns the corresponding response, which is well shown in the Flash animation.

      The problem comes when i want to send something from the server, to, in example, all users. i.e. that each client gets a packet from the server.

      I thought to do that a frame that is sending a packet to the server is being repeating each X time, and that the server is returning the response, reporting if there is new data for all the users. I imagine that sending and receiving so many packets at time, it would do that the server was working so laggy, thats why, I doubt that I will doing it in a correct form.


      The frame that is repeating, checking new data, has got the next code (from a guide):


      var xsTestSocket: XMLSocket = new XMLSocket();
      cbtCallFW.onRelease = function():Void {
          var bSuccess:Boolean = xsTestSocket.connect(ctaServerIP.text, ctaServerPort.text);
      xsTestSocket.onConnect = function(bSuccess:Boolean):Void {
          if (bSuccess) {
              var sFWCmd:String = ctaServerQuest.text;
           ctaServerReply.text = "Connection Timeout.";
      xsTestSocket.onData = function(reply:String):Void {
          ctaServerReply.text = reply;


      To sum up, this code sends a packet that is in a text input to server, waiting a response.


      My question is if repeating so many times this frame, I'm doing it in a correct form. If not, how I could do it?

      Thanks for reading and sorry my bad english