From e3e8a2ea219c309503182b4b5464ca272112c3a8 Mon Sep 17 00:00:00 2001 From: cblgh Date: Tue, 23 Jun 2026 19:28:44 +0200 Subject: [PATCH 1/2] example(connect): loop over incoming to allow multiple conns --- examples/connect/connect.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/connect/connect.go b/examples/connect/connect.go index 831bd04..61dad06 100644 --- a/examples/connect/connect.go +++ b/examples/connect/connect.go @@ -63,7 +63,13 @@ func send(e *iroh.Endpoint, id string) { } func listen(e *iroh.Endpoint) { - incoming := *e.AcceptNext() + for { + incoming := *e.AcceptNext() + go handleIncoming(incoming) + } +} + +func handleIncoming (incoming *iroh.Incoming) { accepting, err := incoming.Accept() check(err) -- 2.52.0 From 322b0a21036beed336b614defd5251e3834b0fd0 Mon Sep 17 00:00:00 2001 From: cblgh Date: Tue, 23 Jun 2026 19:37:06 +0200 Subject: [PATCH 2/2] example(connect): handle timeout on incoming --- examples/connect/connect.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/connect/connect.go b/examples/connect/connect.go index 61dad06..662bbad 100644 --- a/examples/connect/connect.go +++ b/examples/connect/connect.go @@ -4,6 +4,7 @@ import ( "bufio" "flag" "fmt" + "strings" "os" "os/signal" "syscall" @@ -82,7 +83,17 @@ func handleIncoming (incoming *iroh.Incoming) { recv := stream.Recv() for { frame, err := recv.Read(frameSize) - check(err) + // handle timeout + if err != nil { + irohErr := err.(*iroh.IrohError) + errMsg := irohErr.Message() + if strings.HasPrefix(errMsg, "ConnectionLost") { + fmt.Println("lost connection") + break + } else { + check(err) + } + } fmt.Println(string(frame)) } } -- 2.52.0