mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-14 07:34:43 +08:00
1.优化网络库
2.rpc协议在宕机时不会导致整个rpc无法响应
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
type TcpSocketClient struct {
|
||||
conn net.Conn
|
||||
addr string
|
||||
}
|
||||
|
||||
func (slf *TcpSocketClient) Connect(addr string) error{
|
||||
@@ -22,13 +23,17 @@ func (slf *TcpSocketClient) Connect(addr string) error{
|
||||
return err
|
||||
}
|
||||
slf.conn = conn
|
||||
|
||||
slf.addr = addr
|
||||
|
||||
//
|
||||
return nil
|
||||
}
|
||||
|
||||
func (slf *TcpSocketClient) SendMsg(packtype uint16,message proto.Message) error{
|
||||
if slf.conn == nil {
|
||||
return fmt.Errorf("cannt connect %s",slf.addr)
|
||||
}
|
||||
|
||||
var msg MsgBasePack
|
||||
data,err := proto.Marshal(message)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user