I'm using ActionScript to connect to a C# socket server. In the client (ActionScript), I use the following to send data:
var socket:Socket = new Socket("localhost", 8080);
socket.writeUTF("hello");
socket.flush();
In the server (C# 4.0), I use this:
server = new TcpListener(IPAddress.Any, 8080);
server.Start();
TcpClient client = server.AcceptTcpClient();
BinaryReader reader = new BinaryReader(client.GetStream(), Encoding.UTF8);
Console.WriteLine(reader.ReadString());
I'm able to connect trough flash to the server. But the server doesn't receives the message ("hello") from the client. The server just ignores the message like it was not sent. But when I do reader.ReadString() again, I receive the message (so I must read twice to get each input).
I think I know the problem - this is how Flash writes the string: http://livedocs.adobe.com/flex/3/langref/flash/net/Socket.html#writeUTF()
And this is how C# reads it:
http://msdn.microsoft.com/en-us/library/system.io.binaryreader.read7bitencodedint.aspx
Aditional information about how C# reads it (look at Remarks): http://msdn.microsoft.com/en-us/library/system.io.binarywriter.write7bitencodedint.aspx
Can anybody tell me how can I make both client and server communicate using binary data?
Thanks, Moshe.