4 Replies Latest reply on May 28, 2009 1:20 PM by BurritoSmith

    socket chat client with flash




      I'm considering writing a flash client using sockets to connect to a chat server that I've already written in C#.  Unfortunately I don't have any AS experience so was hoping that someone might be able to point me in the right direction (to tutorials or the like for socket connections etc).


      any guidance/help would be most appreciated.





        • 2. Re: socket chat client with flash
          BurritoSmith Level 1

          thanks for the link.  can you tell me, does flash require that certain ports be used for sockets (like silverlight does)?


          I've tried connecting to my server on the port I set up for the silverlight client (4505) and it can't connect....

          • 3. Re: socket chat client with flash
            kglad Adobe Community Professional & MVP

            yes, if you're using as2 you must use the xmlsocket class and you must connect to a tcp port >= 1024.

            • 4. Re: socket chat client with flash
              BurritoSmith Level 1

              ok thanks for the info.  Since my last post I have have rewritten the server with just the bare essentials to connect a socket client to it.  I'm using port 9999 and when I connect with the flash client, I have it printing out on the server that a client has connected...this works, yay!  However, the flash client sits there for about 30 seconds then spits out the message (from the tutorial you linked me), 'Server connection failed!'.


              I've done nothing more on the flash side than what is in the tutorial.  It's obviously connecting to the server as the server is reporting that a new client has connected... any ideas here?


              The server is a simple c# socket listener.  Code below:



              using System;
              using System.Collections.Generic;
              using System.Linq;
              using System.Text;
              using System.IO;
              using System.Net;
              using System.Net.Sockets;
              namespace FlashChatServer
                  class ChatServer
                      TcpListener socketServer;
                      public ChatServer(Form1 obj)
                          socketServer = new TcpListener(IPAddress.Any, 9999);
                          while (true)
                              if (socketServer.Pending())
                                  TcpClient socketConnection = socketServer.AcceptTcpClient();
                                  DateTime now = DateTime.Now;
                                      obj.ApplyText("New Client Connected - " + now.ToString("MM/dd/yyyy h:mm:ss tt") + "\r\n");