title: How to shutdown a rpc server in golang?
body: <pre><code>var listener net.Listener
  if listener, err = net.Listen("tcp",address); err != nil {
      return 
  }
  server = rpc.NewServer()
  server.Register(new(TunnelRPC))
  
  go server.Accept(listener)
  </code></pre>
  
  <p>I started a rpc server using the code above.  Since I want to shut it down, I tried </p>
  
  <pre><code>listener.close()
  </code></pre>
  
  <p>But it does not work, the err is <code>use of closed network connection</code></p>
  
  <p>How to shutdown this rpc server?</p>