14 Star 51 Fork 12

Hprose / hprose-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
socket_client.go 2.18 KB
一键复制 编辑 原始数据 按行查看 历史
Hprose 提交于 2017-01-07 01:10 . Fixed #26
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* rpc/socket_client.go *
* *
* hprose socket client for Go. *
* *
* LastModified: Jan 7, 2017 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
package rpc
import (
"crypto/tls"
"net"
"time"
)
type socketTransport interface {
IdleTimeout() time.Duration
SetIdleTimeout(timeout time.Duration)
MaxPoolSize() int
SetMaxPoolSize(size int)
setCreateConn(createConn func() (net.Conn, error))
sendAndReceive(data []byte, context *ClientContext) ([]byte, error)
close()
}
// SocketClient is base struct for TCPClient and UnixClient
type SocketClient struct {
BaseClient
socketTransport
ReadBuffer int
WriteBuffer int
TLSConfig *tls.Config
}
func (client *SocketClient) initSocketClient() {
client.InitBaseClient()
client.socketTransport = newHalfDuplexSocketTransport()
client.ReadBuffer = 0
client.WriteBuffer = 0
client.TLSConfig = nil
client.SendAndReceive = client.sendAndReceive
}
// TLSClientConfig returns the tls.Config in hprose client
func (client *SocketClient) TLSClientConfig() *tls.Config {
return client.TLSConfig
}
// SetTLSClientConfig sets the tls.Config
func (client *SocketClient) SetTLSClientConfig(config *tls.Config) {
client.TLSConfig = config
}
// Close the client
func (client *SocketClient) Close() {
client.socketTransport.close()
}
Go
1
https://gitee.com/andot/hprose-go.git
git@gitee.com:andot/hprose-go.git
andot
hprose-go
hprose-go
v2.0.4

搜索帮助