func (lc *LoopbackConn) RemoteAddr() (addr net.Addr) {
	return
}
RemoteAddr returns the remote network address.
package libkb
import (
	"bytes"
	"io"
	"net"
	"sync"
	"syscall"
	"time"
)
type LoopbackAddr struct{}
type LoopbackListener struct {
	mutex    sync.Mutex
	ch       chan *LoopbackConn
	isClosed bool
}
type LoopbackConn struct {
	wMutex   sync.Mutex
	isClosed bool
	ch       chan<- []byte
	rMutex    sync.Mutex
	partnerCh <-chan []byte
	buf       bytes.Buffer
}
func NewLoopbackListener() *LoopbackListener {
	return &LoopbackListener{
		ch:       make(chan *LoopbackConn),
		isClosed: false,
	}
}
func NewLoopbackConnPair() (*LoopbackConn, *LoopbackConn) {
	aCh := make(chan []byte)
	bCh := make(chan []byte)
	a := &LoopbackConn{ch: aCh}
	b := &LoopbackConn{ch: bCh}
	a.partnerCh = bCh
	b.partnerCh = aCh
	return a, b
}
func (ll *LoopbackListener) Dial() (net.Conn, error) {
	G.Log.Debug("+ LoopbackListener.Dial")
	ll.mutex.Lock()
	defer ll.mutex.Unlock()
	if ll.isClosed {
		return nil, syscall.EINVAL
	}
	a, b := NewLoopbackConnPair()
	ll.ch <- a
	return b, nil
}
func (ll *LoopbackListener) Accept() (ret net.Conn, err error) {
	G.Log.Debug("+ LoopbackListener.Accept")
	var ok bool
	if ret, ok = <-ll.ch; !ok {
		err = syscall.EINVAL
	}
	G.Log.Debug("- LoopbackListener.Accept -> %v", err)
	return ret, err
}
func (ll *LoopbackListener) Close() (err error) {
	ll.mutex.Lock()
	defer ll.mutex.Unlock()
	if ll.isClosed {
		return syscall.EINVAL
	}
	ll.isClosed = true
	close(ll.ch)
	return
}
func (ll *LoopbackListener) Addr() (addr net.Addr) {
	return LoopbackAddr{}
}
func (lc *LoopbackConn) Read(b []byte) (n int, err error) {
	lc.rMutex.Lock()
	defer lc.rMutex.Unlock()
	if lc.buf.Len() > 0 {
		return lc.buf.Read(b)
	}
	msg, ok := <-lc.partnerCh
	if !ok {
		return 0, io.EOF
	}
	lc.buf.Write(msg)
	return lc.buf.Read(b)
}
func (lc *LoopbackConn) Write(b []byte) (n int, err error) {
	lc.wMutex.Lock()
	defer lc.wMutex.Unlock()
	if lc.isClosed {
		return 0, syscall.EINVAL
	}
	lc.ch <- b
	return len(b), nil
}
func (lc *LoopbackConn) Close() (err error) {
	lc.wMutex.Lock()
	defer lc.wMutex.Unlock()
	if lc.isClosed {
		return syscall.EINVAL
	}
	lc.isClosed = true
	close(lc.ch)
	return nil
}
func (lc *LoopbackConn) LocalAddr() (addr net.Addr) {
	return
}