test
This commit is contained in:
parent
1ea23d65f3
commit
362a8ea83b
25
main.go
25
main.go
@ -21,7 +21,26 @@ func main() {
|
||||
failError(err, "conn.Write")
|
||||
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
||||
|
||||
// listen for reply
|
||||
message, _ := bufio.NewReader(conn).ReadString('\n')
|
||||
logInfoDebug("Message from server: %s", message)
|
||||
for {
|
||||
p := Packet{}
|
||||
b, err := conn.ReadByte()
|
||||
logErrorDebug(err, "conn.ReadByte")
|
||||
p.PLength = uint8(b) << 8
|
||||
b, err = conn.ReadByte()
|
||||
logErrorDebug(err, "conn.ReadByte")
|
||||
p.PLength += uint8(b)
|
||||
b, err = conn.ReadByte()
|
||||
logErrorDebug(err, "conn.ReadByte")
|
||||
p.PType = uint8(b)
|
||||
d := make([]byte, p.PLength-3)
|
||||
|
||||
for {
|
||||
_, err := conn.Read(d[len(d):])
|
||||
logErrorDebug(err, "conn.Read")
|
||||
if len(d) == p.PLength-3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user