-
Notifications
You must be signed in to change notification settings - Fork 43
Conversation
@@ -58,7 +58,7 @@ func run(raddr string, p string) error { | |||
if _, err := str.Write([]byte(msg)); err != nil { | |||
return err | |||
} | |||
if err := str.Close(); err != nil { | |||
if err := str.CloseWrite(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to call close eventually (e.g., in a defer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but streams are automatically closed when the connection is closed, so this is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, this is an example, and we should probably do things the clean way. Will add the defers.
cmd/server/main.go
Outdated
@@ -75,5 +75,5 @@ func handleConn(conn tpt.CapableConn) error { | |||
if _, err := str.Write([]byte(data)); err != nil { | |||
return err | |||
} | |||
return str.Close() | |||
return str.CloseWrite() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto (that or reset)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Actually, in this case, shouldn't it just be a close? I mean, we've already read everything we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works as well. And it's easier.
16f171c
to
091f9df
Compare
cmd/server/main.go
Outdated
@@ -75,5 +75,5 @@ func handleConn(conn tpt.CapableConn) error { | |||
if _, err := str.Write([]byte(data)); err != nil { | |||
return err | |||
} | |||
return str.Close() | |||
return str.CloseWrite() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Actually, in this case, shouldn't it just be a close? I mean, we've already read everything we want.
091f9df
to
92d84b2
Compare
Fixes #220.