blob: 2f8d865e3243a1ccd30a15b9e8d83301f6e144fb [file] [log] [blame]
nickhuang6b31f8f2019-09-26 02:02:14 +00001// Copyright 2018-present Open Networking Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import "net"
18import "fmt"
19import "bufio"
20import "os"
nickhuang6b31f8f2019-09-26 02:02:14 +000021
22func main() {
23 // connect to this socket
24 var message string = ""
25 conn, _ := net.Dial("tcp", "127.0.0.1:9999")
26 reader := bufio.NewReader(os.Stdin)
27 for {
28 // read in input from stdin
mc20a4b5f2019-10-16 20:28:24 +000029 fmt.Print("CMD to send : ")
nickhuang6b31f8f2019-09-26 02:02:14 +000030 text, _ := reader.ReadString('\n')
nickhuang6b31f8f2019-09-26 02:02:14 +000031 // send to socket
32 fmt.Fprintf(conn, text + "\n")
33
mc20a4b5f2019-10-16 20:28:24 +000034 // listen for reply
35 message, _ = bufio.NewReader(conn).ReadString('\n')
36 fmt.Print("Return from server: " + message)
nickhuang6b31f8f2019-09-26 02:02:14 +000037
38 if message == "QUIT\n"{
39 break
40 }
41 }
42}