多路复用流库 Spdystream

码农软件 · 软件分类 · 网络工具包 · 2019-02-25 23:12:26

软件介绍

Spdystream 是使用 spdy 的多路复用流库。

用途示例:

Client example (connecting to mirroring server without auth)

package main

import (
    "fmt"
    "github.com/docker/spdystream"
    "net"
    "net/http"
)

func main() {
    conn, err := net.Dial("tcp", "localhost:8080")
    if err != nil {
        panic(err)
    }
    spdyConn, err := spdystream.NewConnection(conn, false)
    if err != nil {
        panic(err)
    }
    go spdyConn.Serve(spdystream.NoOpStreamHandler)
    stream, err := spdyConn.CreateStream(http.Header{}, nil, false)
    if err != nil {
        panic(err)
    }

    stream.Wait()

    fmt.Fprint(stream, "Writing to stream")

    buf := make([]byte, 25)
    stream.Read(buf)
    fmt.Println(string(buf))

    stream.Close()
}

Server example (mirroring server without auth)

package main

import (
    "github.com/docker/spdystream"
    "net"
)

func main() {
    listener, err := net.Listen("tcp", "localhost:8080")
    if err != nil {
        panic(err)
    }
    for {
        conn, err := listener.Accept()
        if err != nil {
            panic(err)
        }
        spdyConn, err := spdystream.NewConnection(conn, true)
        if err != nil {
            panic(err)
        }
        go spdyConn.Serve(spdystream.MirrorStreamHandler)
    }
}


本文地址:https://www.codercto.com/soft/d/141.html

How to Design Programs, 2nd Edition

How to Design Programs, 2nd Edition

Matthias Felleisen、Robert Bruce Findler、Matthew Flatt、Shriram Krishnamurthi / MIT Press / 2018-5-4 / USD 57.00

A completely revised edition, offering new design recipes for interactive programs and support for images as plain values, testing, event-driven programming, and even distributed programming. This ......一起来看看 《How to Design Programs, 2nd Edition》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具