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")
|
failError(err, "conn.Write")
|
||||||
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
||||||
|
|
||||||
// listen for reply
|
for {
|
||||||
message, _ := bufio.NewReader(conn).ReadString('\n')
|
p := Packet{}
|
||||||
logInfoDebug("Message from server: %s", message)
|
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