streamwriter chopping off the telnet packets

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Naveenv2002
    New Member
    • Oct 2008
    • 1

    streamwriter chopping off the telnet packets

    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:

    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();
    }
    in the above,
    Code:
    System.Console.Write(Encoding.UTF8.GetString(data, offset, length));
    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.
    Last edited by Curtis Rutland; Oct 16 '08, 06:38 PM. Reason: added code tags
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    One of them uses ascii, one uses utf8.

    Comment

    Working...