```
handler := new(BattleHandler)
rpc.Register(handler)
//rpc.HandleHTTP()
tcpAddr, err := net.ResolveTCPAddr("tcp", conf.GetRPCURL())
if err != nil {
common.CheckFatal(false, "[battleServer] Resolve TCP address for RPC fail: "+err.Error())
}
listener, err := net.ListenTCP("tcp", tcpAddr)
defer func() {
listener.Close()
}()
for {
conn, acceptErr := listener.Accept()
if acceptErr != nil {
continue
}
go rpc.ServeConn(conn)
}
```
有疑问加站长微信联系(非本文作者)