I'm trying to send 3 messages from an Android tcp client to a C# Server. It works properly in another C# client, but it doesn't in the Android client. I send 3 messages but the server gets the first message correctly but then the second and the third joined like they were just one message
Server code:
NetworkStream stream = client.GetStream();
byte[] buffer = new byte[client.ReceiveBufferSize];
int data = stream.Read(buffer, 0, client.ReceiveBufferSize);
string message = Encoding.UTF8.GetString(buffer, 0, data);
int one = Int32.Parse(message);
buffer = new byte[client.ReceiveBufferSize];
data = stream.Read(buffer, 0, client.ReceiveBufferSize);
message = Encoding.UTF8.GetString(buffer, 0, data);
int two = Int32.Parse(message);
buffer = new byte[client.ReceiveBufferSize];
data = stream.Read(buffer, 0, client.ReceiveBufferSize);
message = Encoding.UTF8.GetString(buffer, 0, data);
int three = Int32.Parse(message);
the Android client is:
EditText et = (EditText) findViewById(R.id.EditText01);
String one = "56";
String two = "300";
String three = "4";
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.writeBytes(one);
out.flush();
out.writeBytes(two);
out.flush();
out.writeBytes(three);
out.flush();
The server gets: one = 56 two = 3004
Instead of: one = 56 two = 300 three = 4