Created
April 8, 2017 13:50
-
-
Save notchi590/e0bf94d00b2d3ee7c9b4a087cd753099 to your computer and use it in GitHub Desktop.
extreme simple tcp client written in Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"net" | |
"os" | |
) | |
func main() { | |
conn, _ := net.Dial("tcp", "127.0.0.1:8080") | |
for { | |
reader := bufio.NewReader(os.Stdin) | |
fmt.Print("Text to send: ") | |
text, _ := reader.ReadString('\n') | |
fmt.Fprintf(conn, text+"\n") | |
message, _ := bufio.NewReader(conn).ReadString('\n') | |
fmt.Print("Message from server: " + message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment