The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/aws-experiment-launch/experiment/commander/main.go

44 lines
605 B

package main
import (
"log"
"net"
"strconv"
"strings"
)
const (
message = "Ping"
StopCharacter = "\r\n\r\n"
)
func SocketClient(ip string, port int) {
addr := strings.Join([]string{ip, strconv.Itoa(port)}, ":")
conn, err := net.Dial("tcp", addr)
defer conn.Close()
if err != nil {
log.Fatalln(err)
}
conn.Write([]byte(message))
conn.Write([]byte(StopCharacter))
log.Printf("Send: %s", message)
buff := make([]byte, 1024)
n, _ := conn.Read(buff)
log.Printf("Receive: %s", buff[:n])
}
func main() {
var (
ip = "127.0.0.1"
port = 3333
)
SocketClient(ip, port)
}