```
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)
}
```
更多评论