test_review #2

Merged
mihaim merged 2 commits from test_review into master 2022-03-24 00:08:56 +00:00
Showing only changes of commit ddec70f4d7 - Show all commits

View File

@ -5,29 +5,25 @@ import (
"net"
)
/* login to El */
/* Login to El */
func sendLogin(c net.Conn, user string, password string) {
s := user + " " + password
lungime := len(s) + 3
b := make([]byte, lungime+2)
length := len(s) + 3
b := make([]byte, length+2)
b[0] = 140
b[1] = byte(lungime % 256)
b[2] = byte(lungime / 256)
b[1] = byte(length % 256)
b[2] = byte(length / 256)
copy(b[3:], s)
b[lungime+1] = 0
b[length+1] = 0
binary.Write(c, binary.LittleEndian, b)
}
/* Send back to server what we received */
func sendPingReply(c net.Conn, b []byte) {
ping_reply := make([]byte, 7)
ping_reply[0] = b[0]
ping_reply[1] = b[1]
ping_reply[2] = b[2]
ping_reply[3] = b[3]
ping_reply[4] = b[4]
ping_reply[5] = b[5]
ping_reply[6] = b[6]
for i := 0; i < 7; i++ {
ping_reply[i] = b[i]
}
binary.Write(c, binary.LittleEndian, ping_reply)
}