This commit is contained in:
Unknown
2013-06-22 21:29:42 +08:00
parent fac2467441
commit 67be80ca8c
120 changed files with 506 additions and 7307 deletions

View File

@@ -1,36 +0,0 @@
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))
}
}