title: Creating a TCP client in golang
body: <p>Hi i'm attempted to learn some socket programming in golang, I'm following along with this tutorial </p>
  
  <p><a href="http://synflood.at/tmp/golang-slides/mrmcd2012.html#1">http://synflood.at/tmp/golang-slides/mrmcd2012.html#1</a></p>
  
  <p>Here is the final result of the tutorial on one page.
  <a href="https://github.com/akrennmair/telnet-chat/blob/master/03_chat/chat.go">https://github.com/akrennmair/telnet-chat/blob/master/03_chat/chat.go</a></p>
  
  <p>I'm confused on how to write the client side of this program, I create a connection and dial into the same port/ip as the server is running on but from there I don't know. I have read() and write() functions for the newly created connection but no idea where to delimit the read or anything. Considering the text input is handeled in the server I imagine I'd only need to do a read of some kind?</p>
  
  <pre><code>package main
  
  import (
      "bufio"
      "fmt"
      "net"
      "os"
  )
  
  func main() {
      conn, err := net.Dial("tcp", "127.0.0.1:6000")
      if err != nil {
          fmt.Println(err)
          os.Exit(1)
      }
  
      for {
          fmt.Println(bufio.NewReader(conn).ReadString([]byte("\n")))
      }
  
  }
  </code></pre>