correctly handle connection errors in the client

This commit is contained in:
Marten Seemann 2017-02-22 12:41:07 +07:00
parent 96edca5219
commit 8247454b0f
No known key found for this signature in database
GPG key ID: 3603F40B121FCDEA
3 changed files with 22 additions and 13 deletions

View file

@ -14,12 +14,16 @@ type mockPacketConn struct {
addr net.Addr
dataToRead []byte
dataReadFrom net.Addr
readErr error
dataWritten bytes.Buffer
dataWrittenTo net.Addr
closed bool
}
func (c *mockPacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
if c.readErr != nil {
return 0, nil, c.readErr
}
if c.dataToRead == nil { // block if there's no data
time.Sleep(time.Hour)
return 0, nil, io.EOF