dnssecsocket/client/client.go

32 lines
569 B
Go

package main
import "net"
import "fmt"
import "bufio"
import "os"
const (
CONN_HOST = "localhost"
CONN_PORT = "3333"
CONN_PROTO = "tcp"
)
func main() {
// connect to this socket
conn, _ := net.Dial(CONN_PROTO, CONN_HOST+":"+CONN_PORT)
for {
// read in input from stdin
reader := bufio.NewReader(os.Stdin)
fmt.Print("Text to send: ")
text, _ := reader.ReadString('\n')
// send to socket
fmt.Fprintf(conn, text + "\n")
// listen for reply
message, _ := bufio.NewReader(conn).ReadString('\n')
fmt.Print("Message from server: "+message)
}
}