kuryr-tempest-plugin/test_container/udp_client.go
Yossi Boaron 3ae7eef13e Add support for UDP in kuryr/demo container
Update kuryr/demo container to support UDP server.
After this change, the kuryr/demo image runs both HTTP and UDP
servers.
The listeners ports values could be configured using pod's
environment variables.
And in addition, a simple udp client binary tool was added to
image, to use it, you should run :
udp_client <server's_ip> <server's port>

Change-Id: I9f2f2ad3273f947fecb776c0f56f6829df81aa67
2018-10-18 16:37:04 +03:00

31 lines
516 B
Go

package main
import (
"bufio"
"fmt"
"net"
"os"
)
// udp_client.go syntax : udp_client <server_IP> <server_port>
func main() {
server_ip_port := os.Args[1] + ":" + os.Args[2]
p := make([]byte, 2048)
conn, err := net.Dial("udp", server_ip_port)
if err != nil {
fmt.Printf("Some error %v", err)
return
}
fmt.Fprintf(conn, "Hi UDP Server, How are you?")
_, err = bufio.NewReader(conn).Read(p)
if err == nil {
fmt.Printf("%s\n", p)
} else {
fmt.Printf("Some error %v\n", err)
}
conn.Close()
}