3 Yamux (Yet another Multiplexer) is a multiplexing library for Golang.
4 It relies on an underlying connection to provide reliability
5 and ordering, such as TCP or Unix domain sockets, and provides
6 stream-oriented multiplexing. It is inspired by SPDY but is not
9 Yamux features include:
11 * Bi-directional streams
12 * Streams can be opened by either client or server
13 * Useful for NAT traversal
14 * Server-side push support
17 * Back-pressure to prevent overwhelming a receiver
19 * Enables persistent connections over a load balancer
21 * Enables thousands of logical streams with low overhead
25 For complete documentation, see the associated [Godoc](http://godoc.org/github.com/hashicorp/yamux).
29 The full specification for Yamux is provided in the `spec.md` file.
30 It can be used as a guide to implementors of interoperable libraries.
34 Using Yamux is remarkably simple:
39 // Get a TCP connection
40 conn, err := net.Dial(...)
45 // Setup client side of yamux
46 session, err := yamux.Client(conn, nil)
52 stream, err := session.Open()
57 // Stream implements net.Conn
58 stream.Write([]byte("ping"))
62 // Accept a TCP connection
63 conn, err := listener.Accept()
68 // Setup server side of yamux
69 session, err := yamux.Server(conn, nil)
75 stream, err := session.Accept()
80 // Listen for a message
81 buf := make([]byte, 4)