reiver / go-telnet

Package telnet provides TELNET and TELNETS client and server implementations, for the Go programming language, in a style similar to the "net/http" library that is part of the Go standard library, including support for "middleware"; TELNETS is secure TELNET, with the TELNET protocol over a secured TLS (or SSL) connection.
https://godoc.org/github.com/reiver/go-telnet
MIT License
257 stars 82 forks source link

How to Read data unblock? #12

Open zhougb3 opened 5 years ago

zhougb3 commented 5 years ago

Now I use telnet.DialTo to get a conn.I use this conn to Read bytes using the function conn.Read().However,it is blocked.How can I solve this problem,thank you! Idon't know how many bytes i will receive.ButI want to receive all of them

calvincramer commented 6 months ago

I did some testing on this problem. I was using an expect library on top of the telnet connection. The issue I saw was that the reiver telnet connection would block forever until all bytes are available.

I solved this using a different telnet library https://pkg.go.dev/github.com/ziutek/telnet

I tested ziutek's library by making a simple telnet server that just sends a simple message when clients connect, and could see on Read() with zuitek any unavailable bytes will be set to 0 (eager read), while the reiver connection will block.