title: How to listen to a client continiously using gob in Golang
body: <p>In my use case I would like to continuously listen to a TCP connection and receive the value. The expected value is an object. So I am using gob decoder to receive the value from the connection. I would like to continuously listen to the connection and receive the object using go routines. I have the code snippet here[It is part of the application. code snippet does not compile]. It is getting value for the first time but not receiving for the subsequent objects.</p>
  
  <pre><code>func main() {
  
      //...
      // SOME CODE
      //...
  
  
      // All hosts who are connected; a map wherein
      // the keys are ip addreses and the values are
      //net.Conn objects
      allClients := make(map[string]net.Conn)
  
      tMaps := make(chan map[string]int64)
  
      for {
              select {
              // Accept new clients
              //
              case conn := &lt;-newConnections:
              log.Printf("Accepted new client, #%s", hostIp)
  
              // Constantly read incoming messages from this
              // client in a goroutine and push those onto
              // the tMaps channel for broadcast to others.
              //
              go func(conn net.Conn) {
                      dec := gob.NewDecoder(conn)
                      for {
                              var tMap map[string]int64
                              err := dec.Decode(&amp;tMap)
                              if err != nil {
                                      fmt.Println("Error in decoding ", err)
                                      break
                              }
                              log.Printf("Received values: %+v", tMap)
                              //update throttle map based on the received value
                              tMaps &lt;- throttleMap
                      }
  
              }(conn)
      }
  }
  </code></pre>
  
  <p>Could anyone help me on this?</p>