Example #1
0
File: msg.go Project: nictuku/bitz
func parseVersion(r io.Reader) (versionMessage, error) {
	v := &binaryVersionMessage{}
	check(binary.Read(r, binary.BigEndian, v))
	fmt.Println("version", v.Version)
	fmt.Println("addr recv", parseIP(v.AddrRecv.IP))

	userAgent, _, _ := encVarstring.ReadVarString(r)
	streams := readVarIntList(r)
	version := versionMessage{*v, userAgent, streams}
	return version, nil
}
Example #2
0
func (this *DataReader) ReadVarString() (string, error) {
	value, i, err := varstring.ReadVarString(this.r)
	this.count += int64(i)
	return value, err
}