This commit is contained in:
Unknown
2013-05-07 23:43:09 -04:00
parent 9f0b4ae8c1
commit ffca9f3c2b
97 changed files with 7353 additions and 57 deletions

View File

@@ -0,0 +1,36 @@
package main
import (
"fmt"
"os"
"net"
"bufio"
"strings"
)
func main() {
conn, err := net.Dial("tcp", "localhost:50000")
if err != nil {
// No connection could be made because the target machine actively refused it.
fmt.Println("Error dialing", err.Error())
return // terminate program
}
inputReader := bufio.NewReader(os.Stdin)
fmt.Println("First, what is your name?")
clientName, _ := inputReader.ReadString('\n')
// fmt.Printf("CLIENTNAME %s",clientName)
trimmedClient := strings.Trim(clientName, "\r\n") // "\r\n" on Windows, "\n" on Linux
for {
fmt.Println("What to send to the server? Type Q to quit.")
input, _ := inputReader.ReadString('\n')
trimmedInput := strings.Trim(input, "\r\n")
// fmt.Printf("input:--%s--",input)
// fmt.Printf("trimmedInput:--%s--",trimmedInput)
if trimmedInput == "Q" {
return
}
_, err = conn.Write([]byte(trimmedClient + " says: " + trimmedInput))
}
}