0
Reply

XMLSocket & C#

unnevermind

unnevermind

Dec 19 2004 8:07 AM
3.5k
Hi I'm a flash programmer and new member...sorry my english not well...but I will try.... ....I tried to search on google...How to send data between Flash XMLSocket and C# Socket... I found only with Java but no any site talk about how to with c#... I found this website and downloaded demo version at http://www.dart.com/dotnet/sockets.asp that can do with vb.net I got an example project but all I need to know are in Dart.PowerTCP.Sockets.DLL :( I'm a new C# user ... just 2 week :) T tried again with my stupid OOP :( ..... [C# Demo] using System; using System.Text; using System.Net; using System.Net.Sockets; namespace XMLServer { class Class1 { static int port = 10000; static TcpListener server; static IPAddress[] local =Dns.Resolve(Dns.GetHostName()).AddressList; /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { Console.WriteLine("Server started : " + local[0] + ":" + port); start(); } static void Listen() { while (true) { Socket mysock = server.AcceptSocket(); if (mysock.Connected) { string ip = mysock.RemoteEndPoint.ToString(); byte[] rec = new byte[1024]; mysock.Receive(rec); char[] sp = Encoding.ASCII.GetChars(new byte[]{0}); string str = Encoding.ASCII.GetString(rec).TrimEnd(sp); Console.WriteLine(ip+" : "+str); DateTime t = new DateTime(); byte[] res = Encoding.ASCII.GetBytes("Message : " + t.ToString()); mysock.Send(res);//<------ not work mysock.Close(); } } } static void start() { server = new TcpListener(local[0], port); try { server.Start(); Listen(); } catch (Exception e) { server.Stop(); Console.WriteLine(e.ToString()); } } } } [ActionScript Demo] var port = 10000; var server = "127.0.0.1"; xml = new XMLSocket(); xml.onConnect = function(success) { boxrec.text += "connected....\n"; }; xml.onXML = function(data) { trace("xml : "+data.toString()); }; _root.bsend.onRelease = function() { xml.connect(server, port); xml.send(boxsend.text); }; It can send data from flash to c# but can not send from c# to flash.... :( anyone can help me thank you.... ----------------------------------------------