0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

reduce number of packets

This commit is contained in:
Zack Scholl 2018-10-09 04:50:38 -07:00
parent fdfa7f209d
commit 66a37ae5b2

View file

@ -32,11 +32,9 @@ func (c Comm) Close() {
c.connection.Close()
}
func (c Comm) Write(b []byte) (int, error) {
c.connection.Write([]byte(fmt.Sprintf("%0.5d", len(b))))
n, err := c.connection.Write(b)
if n != len(b) {
n, err := c.connection.Write(append([]byte(fmt.Sprintf("%0.5d", len(b))), b...))
if n != len(b)+5 {
err = fmt.Errorf("wanted to write %d but wrote %d", n, len(b))
}
// log.Printf("wanted to write %d but wrote %d", n, len(b))