README.md 955 Bytes
Newer Older
Steven Allen's avatar
Steven Allen committed
1
# go-mplex
Jeromy's avatar
Jeromy committed
2

Yusef Napora's avatar
Yusef Napora committed
3
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
Yusef Napora's avatar
Yusef Napora committed
4 5 6 7
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](https://libp2p.io/)
[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)

Alan Shaw's avatar
Alan Shaw committed
8
A super simple [stream muxing](https://docs.libp2p.io/concepts/stream-multiplexing/) library implementing [mplex](https://github.com/libp2p/specs/tree/master/mplex).
Jeromy's avatar
Jeromy committed
9 10 11 12 13 14

## Usage

```go
mplex := multiplex.NewMultiplex(mysocket)

Jeromy's avatar
Jeromy committed
15
s, _ := mplex.NewStream()
Jon Choi's avatar
Jon Choi committed
16
s.Write([]byte("Hello World!"))
Jeromy's avatar
Jeromy committed
17 18
s.Close()

Jeromy's avatar
Jeromy committed
19 20 21
os, _ := mplex.Accept()
// echo back everything received
io.Copy(os, os)
Jeromy's avatar
Jeromy committed
22
```
23 24 25 26

---

The last gx published version of this module was: 0.2.35: QmWGQQ6Tz8AdUpxktLf3zgnVN9Vy8fcWVezZJSU3ZmiANj