views:

66

answers:

2

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.

A: 

arent there writeBytes for binary data? so you would 1st put string into byte array and then send those.

fuck
Please read my problem again. I need to know how to write a string with flash so C# will be able to read it. (and all must be binary data, no JSON or something)
Zippo
so is it like you minus me because i dont give you ready-to-use code? ha ha.
fuck
A: 

You can close this question, I see nobody knows the answer.

Zippo