9swampy / Telnet

Published on Nuget at https://www.nuget.org/packages/Telnet
http://www.nugetmusthaves.com/Package/Telnet
MIT License
124 stars 50 forks source link

TerminatedRead does not behave correctly #80

Open ShehzadNaeem-TMMC opened 2 days ago

ShehzadNaeem-TMMC commented 2 days ago

TerminatedReadAsync(terminator, timeout) does not actually terminate the read at the inputted termintor character.

For example, when the stream contains the following bytes: \n \nXX\r\nYYYY YY YY YYYYYYY YYYYYYYY \"ZZZZ\"\r\n

and terminated read is called as await TerminatedReadAsync(PrimS.Telnet.Client.Rfc854LineFeed, ReadTimeout)

it is expected that only \n \nXX\r\n is returned.

Instead the entire contents of the stream is returned.

This is because, in ByteStreamHandlerCancellable line 89, RetrieveAndParseResponse(sb) is looped over the entire contents of the stream without checking for the terminator.

The check for the terminator is only done by the calling method in Client.cs line 154 when all the bytes from the stream have already been returned.

Have I misunderstood how this method is supposed to work?