Here's how you would implement basic RPC-style request/response.
On the client:
var ch libchan.Sender
// Send a message, indicate that we want a return channel to be automatically created
ret1, err := ch.Send(&libchan.Message{Data: []byte("request 1!"), Ret: libchan.RetPipe})
// Send another message on the same channel
ret2, err := ch.Send(&libchan.Message{Data: []byte("request 2!"), Ret: libchan.RetPipe})
// Wait for an answer from the first request. Set flags to zero
// to indicate we don't want a nested return channel
msg, err := ret1.Receive(0)
fmt.Printf("Received answer: %s\n", msg.Data)
On the server:
var ch libchan.Receiver
// Wait for messages in a loop
// Set the return channel flag,
// to indicate we want to receive nested channels (if any).
// Note: we don't send a nested return channel, but we could.
for {
msg, err := ch.Receive(libchan.Ret)
msg.Ret.Send(&libchan.Message{Data: []byte("this is an utterly useless response")})
}