package main import ( "bufio" "net" ) func main() { conn, err := net.Dial("tcp", "poop.siteop.biz:3977") failError(err, "net.Dial") logInfoDebug("Connected to poop.siteop.biz:3977") //send auth p := PacketAdminJoin{ Packet: Packet{PType: AdminPacketAdminJoin}, Password: "plop", AppName: "gottdad", AppVersion: "alpha", } _, err = conn.Write(p.Bytes()) failError(err, "conn.Write") logInfoDebug("Authentication sent (%v)", p.Bytes()) r := bufio.NewReader(conn) for { p := Packet{} b, err := r.ReadByte() logErrorDebug(err, "conn.ReadByte") p.PLength = uint8(b) << 8 b, err = r.ReadByte() logErrorDebug(err, "conn.ReadByte") p.PLength += uint8(b) b, err = r.ReadByte() logErrorDebug(err, "conn.ReadByte") p.PType = uint8(b) if p.PLength <= 3 { logInfoAlert("Wrong packet length") break } d := make([]byte, p.PLength-3) for { _, err := r.Read(d[len(d):]) logErrorDebug(err, "conn.Read") if len(d) == int(p.PLength-3) { break } } logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType) } }