Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

socket chat client with flash

New Here ,
May 28, 2009 May 28, 2009

Hello,

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.

thanks,

Burr

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2009 May 28, 2009

http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 28, 2009 May 28, 2009

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....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2009 May 28, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 28, 2009 May 28, 2009
LATEST

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)
            {
                socketServer.Start();
                if (socketServer.Pending())
                {
                    TcpClient socketConnection = socketServer.AcceptTcpClient();
                    DateTime now = DateTime.Now;
                    if(socketConnection.Connected)
                        obj.ApplyText("New Client Connected - " + now.ToString("MM/dd/yyyy h:mm:ss tt") + "\r\n");
                   
                }
            }
        }
    }
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines