go-pop3 icon indicating copy to clipboard operation
go-pop3 copied to clipboard

fix read and write I/O timeout.

Open ly020044 opened this issue 3 years ago • 4 comments

If the connected pop3 server port is not open, the timeout option will not take effect.

ly020044 avatar May 18 '22 07:05 ly020044

Thanks for the PR. This should ideally be new params called opt.ReadTimeout and opt.WriteTimeout. In addition, the timeouts should be reset on encountering ErrDeadlineExceeded.

knadh avatar May 19 '22 05:05 knadh

By reset do you mean when the io.Reader or io.Writer encounters os.ErrDeadlineExceeded? I don't understand, thanks!

ly020044 avatar May 19 '22 12:05 ly020044

After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.

It is explained in the comments here: https://pkg.go.dev/net#Conn

Basically, if a connection times out, if it has to be reused, its deadlines have to be set again.

knadh avatar May 20 '22 06:05 knadh

Thanks for reply!

ly020044 avatar May 20 '22 08:05 ly020044