Open smegeath opened 3 years ago
according to the documentation for io.Reader
If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more.
This library does not follow that convention. It appears to block until it is able to fill the buffer.
Output:
=== Buffer Size 7 ===
2022/03/30 15:45:06 EOF:false> "hello w"
2022/03/30 15:45:16 EOF:true> "orld\n"
=== Buffer Size 1 ===
2022/03/30 15:45:16 EOF:false> "h"
2022/03/30 15:45:16 EOF:false> "e"
2022/03/30 15:45:16 EOF:false> "l"
2022/03/30 15:45:16 EOF:false> "l"
2022/03/30 15:45:16 EOF:false> "o"
2022/03/30 15:45:16 EOF:false> " "
2022/03/30 15:45:16 EOF:false> "w"
2022/03/30 15:45:16 EOF:false> "o"
2022/03/30 15:45:16 EOF:false> "r"
2022/03/30 15:45:16 EOF:false> "l"
2022/03/30 15:45:16 EOF:false> "d"
2022/03/30 15:45:16 EOF:false> "\n"
2022/03/30 15:45:26 EOF:true> ""
Note that with a buffer size of 7 you immediately get hello w
then you have to wait the full 10 seconds to get orld\n
. A quick test with a debugger shows that it is hanging here
As a work around, you can use a buffer size of 1
I am not able to re-produce the behavior OP describes where the connection ever becomes interactive.
I have confirmed that this is fixed by either of PR #22 or PR #9.
My telnet client is connecting to a non-go-telnet server and uses the basic client code provided in the documentation example. Connecting to my server with a standard telnet client gets an instant reply, but for some reason, my go-telnet client hangs reading for exactly a minute, then is fully interactive. Is there some configuration I should be using or something extra I should be doing with the Conn to flush it?