【文件属性】:
文件名称:cmux:GoLang的连接多路复用器
文件大小:31KB
文件格式:ZIP
更新时间:2021-05-03 11:30:41
Go
cmux:连接多路复用器
cmux是通用的Go库,用于根据有效负载对连接进行多路复用。 使用cmux,可以在同一TCP侦听器上提供gRPC,SSH,HTTPS,HTTP,Go RPC以及几乎所有其他协议的服务。
如何
只需创建您的主侦听器,为该侦听器创建一个cmux,然后匹配连接即可:
// Create the main listener.
l , err := net . Listen ( "tcp" , ":23456" )
if err != nil {
log . Fatal ( err )
}
// Create a cmux.
m := cmux . New ( l )
// Match connections in order:
// First grpc, then HTTP, and otherwise Go RPC/TCP.
grpcL := m . Match
【文件预览】:
cmux-master
----.gitignore(266B)
----README.md(3KB)
----doc.go(791B)
----patricia.go(3KB)
----LICENSE(11KB)
----bench_test.go(3KB)
----go.mod(102B)
----buffer.go(2KB)
----cmux_test.go(17KB)
----cmux.go(7KB)
----patricia_test.go(2KB)
----example()
--------example_recursive_test.go(3KB)
--------go.mod(371B)
--------go.sum(8KB)
--------example_tls_test.go(2KB)
--------example_test.go(3KB)
----matchers.go(7KB)
----CONTRIBUTORS(438B)
----go.sum(1KB)
----.travis.yml(715B)