Skip to content

Instantly share code, notes, and snippets.

@asergeyev
Created January 28, 2013 18:20
Show Gist options
  • Save asergeyev/4657796 to your computer and use it in GitHub Desktop.
Save asergeyev/4657796 to your computer and use it in GitHub Desktop.
diff --git a/client.go b/client.go
index 7842cfc..a12f4ba 100644
--- a/client.go
+++ b/client.go
@@ -47,6 +47,7 @@ func (c *Client) Exchange(m *Msg, a string) (r *Msg, rtt time.Duration, err erro
if err = w.dial(); err != nil {
return nil, 0, err
}
+ defer w.close()
if err = w.send(m); err != nil {
return nil, 0, err
}
@@ -267,6 +268,10 @@ func (w *reply) write(p []byte) (n int, err error) {
return
}
+func (w *reply) close() {
+ w.conn.Close()
+}
+
func setTimeouts(w *reply) {
if w.client.ReadTimeout == 0 {
w.conn.SetReadDeadline(time.Now().Add(2 * 1e9))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment