forked from davyxu/cellnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpeer_tcp.go
More file actions
50 lines (35 loc) · 963 Bytes
/
peer_tcp.go
File metadata and controls
50 lines (35 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cellnet
import "time"
// TCP
type TCPSocketOption interface {
// 收发缓冲大小,默认-1
SetSocketBuffer(readBufferSize, writeBufferSize int, noDelay bool)
// 设置最大的封包大小
SetMaxPacketSize(maxSize int)
// 设置读写超时,默认0,不超时
SetSocketDeadline(read, write time.Duration)
}
// TCP接受器,具备会话访问
type TCPAcceptor interface {
GenericPeer
// 访问会话
SessionAccessor
TCPSocketOption
// 查看当前侦听端口,使用host:0 作为Address时,socket底层自动分配侦听端口
Port() int
}
// TCP连接器
type TCPConnector interface {
GenericPeer
TCPSocketOption
// 设置重连时间
SetReconnectDuration(time.Duration)
// 获取重连时间
ReconnectDuration() time.Duration
// 默认会话
Session() Session
// 设置会话管理器 实现peer.SessionManager接口
SetSessionManager(raw interface{})
// 查看当前连接使用的端口
Port() int
}