I'm connected to the device I want to query through sockets. I can send commands no problem but when I try to get data back, it will send it back to me in portions so that I never really get the entire message at once. I've resorted to the multiple try-catch sequence to try to get the different portions successively but I just end up with the last chunk. I'm thinking there is a timing issue but not sure, also, the textboxes don't show any text when the code is done, I figure they should at least display some part of what was received. Any suggestions would be much appreciated
Byte[] Backdata = new byte[64]; //also tried 32, 16, 64
MoxaClient = new TcpClient();
MoxaClient.Connect(NportAddress, NportPort);
datastream = MoxaClient.GetStream();
datastream.Write(SCPIcommands, 0, SCPIcommands.Length);
//Function to wait for all responses
try
{
datastream.Read(Backdata, 0, Backdata.Length);
textBox1.Text += Convert.ToChar(Backdata.ToString());
}
catch
{}
try
{
datastream.Read(Backdata, 4, Backdata.Length);
textBox1.Text += Convert.ToChar(Backdata.ToString());
}
catch{}