updated server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
@@ -8,6 +9,9 @@ import (
|
||||
|
||||
func main() {
|
||||
serv, err := net.ListenPacket("udp4", ":8888")
|
||||
serverIP := "1.1.2.2"
|
||||
msg := "clientapi: " + serverIP
|
||||
b64Msg := base64.StdEncoding.EncodeToString([]byte(msg))
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -19,7 +23,7 @@ func main() {
|
||||
|
||||
for {
|
||||
|
||||
n, addr, err := serv.ReadFrom(buff)
|
||||
_, addr, err := serv.ReadFrom(buff)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -35,10 +39,9 @@ func main() {
|
||||
conn, _ := net.DialUDP("udp4", nil, remote)
|
||||
defer conn.Close()
|
||||
|
||||
conn.Write([]byte("Hello"))
|
||||
conn.Write([]byte(b64Msg))
|
||||
conn.Close()
|
||||
|
||||
fmt.Printf("%s sent this: %s\n", addr, buff[:n])
|
||||
|
||||
fmt.Printf("Sending %s to %s\n", b64Msg, addr)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user