diff options
Diffstat (limited to 'soundbox')
-rw-r--r-- | soundbox/streaming.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/soundbox/streaming.go b/soundbox/streaming.go index 357fa30..3eb237d 100644 --- a/soundbox/streaming.go +++ b/soundbox/streaming.go @@ -13,24 +13,23 @@ const writeTimeout = 1 * time.Second func streamContext(ctx context.Context, r io.Reader, targets []net.HardwareAddr) error { conns := make([]net.Conn, 0) + writers := make([]io.Writer, 0) + for _, target := range targets { conn, err := dialContext(ctx, target) if err != nil { return err } conns = append(conns, conn) + writers = append(writers, conn) } + defer func() { for _, conn := range conns { conn.Close() } }() - writers := make([]io.Writer, 0) - for _, conn := range conns { - writers = append(writers, conn) - } - mw := io.MultiWriter(writers...) buf := make([]byte, bufferSize) |