I am using granados parser for connecting to the telnet and get the data from it. However, every thing appears to be going smooth. But for some reason when I try to write to a string or streamwriter, it looses the final packet. Strangely, If I output the datapackets from the telnet server, it perfectly gets all the packets.
the code snippet is below:
in the above,
outputs the data correctly, however,
in the outputdata string the last packets gets chopped off.
Can someone help what's happening behind. Or is it something I am missing while writing to a file.
the code snippet is below:
Code:
StreamWriter sw = new StreamWriter("c:\\output.txt", true);
public void OnData(byte[] data, int offset, int length)
{
System.Console.Write(Encoding.UTF8.GetString(data, offset, length));
outputdata = (Encoding.ASCII.GetString(data, offset, length));
sw.Write(outputdata);
//sw.Close();
}
Code:
System.Console.Write(Encoding.UTF8.GetString(data, offset, length));
in the outputdata string the last packets gets chopped off.
Can someone help what's happening behind. Or is it something I am missing while writing to a file.
Comment