test_review #2
22
sending.go
22
sending.go
@ -5,29 +5,25 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* login to El */
|
/* Login to El */
|
||||||
func sendLogin(c net.Conn, user string, password string) {
|
func sendLogin(c net.Conn, user string, password string) {
|
||||||
s := user + " " + password
|
s := user + " " + password
|
||||||
lungime := len(s) + 3
|
length := len(s) + 3
|
||||||
b := make([]byte, lungime+2)
|
b := make([]byte, length+2)
|
||||||
b[0] = 140
|
b[0] = 140
|
||||||
b[1] = byte(lungime % 256)
|
b[1] = byte(length % 256)
|
||||||
b[2] = byte(lungime / 256)
|
b[2] = byte(length / 256)
|
||||||
copy(b[3:], s)
|
copy(b[3:], s)
|
||||||
b[lungime+1] = 0
|
b[length+1] = 0
|
||||||
binary.Write(c, binary.LittleEndian, b)
|
binary.Write(c, binary.LittleEndian, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send back to server what we received */
|
/* Send back to server what we received */
|
||||||
func sendPingReply(c net.Conn, b []byte) {
|
func sendPingReply(c net.Conn, b []byte) {
|
||||||
ping_reply := make([]byte, 7)
|
ping_reply := make([]byte, 7)
|
||||||
ping_reply[0] = b[0]
|
for i := 0; i < 7; i++ {
|
||||||
ping_reply[1] = b[1]
|
ping_reply[i] = b[i]
|
||||||
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]
|
|
||||||
binary.Write(c, binary.LittleEndian, ping_reply)
|
binary.Write(c, binary.LittleEndian, ping_reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user