Need help with streamReader... I've written small C# program to read tcp port to capture scale weight from vendor... My problem is program works but after 10 minutes (consistently every 10 minutes), the string value is null causing the program to jump to catch block and exit out of loop... How do I handle null returned in the string??
I have tried this statement:
while ((outputString = streamReader.ReadLine()) != null)
but it hangs and doesn't continue to read...
Thanks in advance...
Here is current partial code:
// Setup stream to read socket data
NetworkStream networkStream = socketForServer.GetStream();
System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
// Setup connection to database and open the connection
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["CnStr"].ToString());
// Set error variable
Boolean _err = false;
// Process data from socket
// Try to process data
// read the data from the host
outputString = streamReader.ReadLine();
// Write data to command window
// Split data into an array
string a = new string;
a = outputString.Split('|');
// Fix station number, remove when fixed by vendor
if (a == "0")
a = WS;