BitTorrent peer write test

This commit is contained in:
liwei committed 2019-05-27 19:18:28 +08:00
1 parent 41ff983b73
commit 03fbdcda60
15 files changed
+649 -188

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
package main
import (
"bytes"
"encoding/binary"
"fmt"
)
type User struct {
Age uint32
Sex byte
Name [20]byte
}
type Buffer struct {
buf []byte
limit int
}
func NewBuffer(buf []byte) *Buffer {
return &Buffer{
buf: buf,
limit: 0,
}
}
func main() {
user := &User{1, 2, [20]byte{}}
buf := new(bytes.Buffer)
binary.Write(buf, binary.LittleEndian, user)
fmt.Println(buf.Bytes())
}
/*func (buffer Buffer) ReadByte() (byte, error) {
}
func (buffer Buffer) ReadByte() (byte, error)() {
}
*/