I have established a connection with a Tomcat java server.
After sending login data, the server responds. The length of the response is not known.
So I'm trying to read byte after byte using DataReader.UnconsumedBufferLength
DataReader din = new DataReader(socket.InputStream);
int i = 0;
byte[] b = new byte[64];
await din.LoadAsync(1);
while(din.UnconsumedBufferLength > 0)
{
din.LoadAsync(1);
b[i] = din.ReadByte();
await din.LoadAsync(1)
i++;
}
This solution kind of works, I get the message into the byte array, but it is far from ideal. The corresponding Java client uses this little line of code
BufferedInputStream inFromServer = new BufferedInputStream(socket.getInputStream());
int read = 0;
byte[] result = new byte[100];
read = inFromServer.read(result);
I wish there was a equally simple solution in C#....