Skip to content

Instantly share code, notes, and snippets.

@notchi590
Created April 8, 2017 13:50
Show Gist options
  • Save notchi590/e0bf94d00b2d3ee7c9b4a087cd753099 to your computer and use it in GitHub Desktop.
Save notchi590/e0bf94d00b2d3ee7c9b4a087cd753099 to your computer and use it in GitHub Desktop.
extreme simple tcp client written in Golang
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