Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: close listener, connection and stream in echo client and server #4188

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: add close func in example
Signed-off-by: rfyiamcool <[email protected]>
  • Loading branch information
rfyiamcool committed Dec 5, 2023
commit 18414e979b9bd5e367ec408b0ddbdb925931ac1a
4 changes: 4 additions & 0 deletions example/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ func echoServer() error {
if err != nil {
return err
}
defer conn.CloseWithError(0, "")
marten-seemann marked this conversation as resolved.
Show resolved Hide resolved

stream, err := conn.AcceptStream(context.Background())
if err != nil {
panic(err)
}
defer stream.Close()

// Echo through the loggingWriter
_, err = io.Copy(loggingWriter{stream}, stream)
return err
Expand All @@ -61,6 +64,7 @@ func clientMain() error {
if err != nil {
return err
}
defer conn.CloseWithError(0, "")

stream, err := conn.OpenStreamSync(context.Background())
if err != nil {
Expand Down