• Kirill Smelkov's avatar
    xnet/pipenet: Package for TCP-like synchronous in-memory network of net.Pipes · d3a7a196
    Kirill Smelkov authored
    This patch adds pipenet - virtual network of net.Pipes.
    
    Addresses on pipenet are host:port pairs. A host is xnet.Networker and so
    can be worked with similarly to regular TCP network with Dial/Listen/Accept/...
    
    Example:
    
        net := pipenet.New("")
        h1 := net.Host("abc")
        h2 := net.Host("def")
    
        l, err := h1.Listen(":10")       // starts listening on address "abc:10"
        go func() {
                csrv, err := l.Accept()  // csrv will have LocalAddr "abc:10"
        }()
        ccli, err := h2.Dial("abc:10")   // ccli will have RemoteAddr "def:10"
    
    Pipenet might be handy for testing interaction of networked applications in 1
    process without going to OS networking stack.
    d3a7a196
pipenet.go 10.5 KB