OK, it looks like each peer is sending multiple messages, which is all getting recevied on the other end as a single byte array. Do I need to figure out how to divide up the byte array?

Change-Id: Icb52eb513d2d135db3137a8e7e4e51dea1c8891e
diff --git a/runtime/internal/flow/conn/grpc/conn.go b/runtime/internal/flow/conn/grpc/conn.go
index 5cbd6f3..11cbd0c 100644
--- a/runtime/internal/flow/conn/grpc/conn.go
+++ b/runtime/internal/flow/conn/grpc/conn.go
@@ -6,13 +6,13 @@
 
 import (
 	"bytes"
-	"encoding/binary"
+	_ "encoding/binary"
 	"errors"
 	"fmt"
 	"io"
 	"log"
 	"net"
-	_ "runtime/debug"
+	"runtime/debug"
 	"sync"
 	"time"
 
@@ -26,6 +26,7 @@
 // TODO: do I need to check the message size as in box_coipher.Seal?
 // TODO: make all these keys not pointers?
 // TODO: should I have locks here?
+// TODO: what's all this salsa stuff?
 type conn struct {
 	rawConn   net.Conn
 	publicKey *[32]byte
@@ -43,7 +44,7 @@
 	log.Printf("Beginning to Read.\n")
 	resBuf := make([]byte, 4096*4096) // TODO better (dynamic) size or way of reading?
 	bytesRead, err := c.rawConn.Read(resBuf)
-	log.Printf("Read %d bytes.\n", bytesRead)
+	log.Printf("Read %d bytes: %v\n", bytesRead, resBuf[:bytesRead])
 	if err != nil {
 		log.Printf("Failed to read.\n")
 		log.Fatal(err)
@@ -60,8 +61,10 @@
 	}
 	copy(b, out)
 	// should we return bytesRead or len(b)?
-	log.Printf("Succeeded in reading.\n")
-	return bytesRead, nil
+	log.Printf("cap(b): %d, len(b) %d, \ncap(out): %d, len(out): %d\n", cap(b), len(b), cap(out), len(out))
+	log.Printf("Succeeded in reading.\n\n")
+	// return bytesRead, nil
+	return len(b), nil
 }
 
 // TODO: all this casting is gross
@@ -87,8 +90,10 @@
 		log.Fatal(err)
 		return -1, errors.New(errMsg)
 	}
-	log.Printf("Succeeded in writing!\n")
-	return int(bytesCopied), nil
+	log.Printf("cap(b): %d, len(b) %d, cap(out): %d, len(out): %d\n", cap(b), len(b), cap(out), len(out))
+	log.Printf("Succeeded in writing!\n\n")
+	// return int(bytesCopied), nil
+	return len(b), nil
 }
 
 // TODO: cover these up with an interface?
@@ -96,6 +101,8 @@
 func (c *conn) Close() error {
 	c.mu.Lock()
 	defer c.mu.Unlock()
+	debug.PrintStack()
+	// log.Fatalf("DON'T CLOSE THE CONNETION\n")
 	return c.rawConn.Close()
 }
 
@@ -134,7 +141,9 @@
 	return &c.nonce
 }
 
+// TODO: re enable.
 func (c *conn) advanceNonce() {
-	c.counter++
-	binary.LittleEndian.PutUint64(c.nonce[:], c.counter)
+
+	// c.counter++
+	// binary.LittleEndian.PutUint64(c.nonce[:], c.counter)
 }