长安链源码分析之网络模块 net-liquid(9)
作者:李
- 2022-10-20 湖南
本文字数:889 字
阅读完需:约 1 分钟
本文已参与「开源摘星计划」,欢迎正在阅读的你加入。活动链接:https://github.com/weopenprojects/WeOpen-Star
连接(Conn)
// Conn defined a connection with remote peer.
//conn 定义了一个连接远程节点的连接
type Conn interface {
io.Closer
//存储连接和流的元数据
Stat
// LocalAddr is the local net multi-address of the connection.
//返回本地网络多地址
LocalAddr() ma.Multiaddr
// LocalNetAddr is the local net address of the connection.
//返回本地网络地址
LocalNetAddr() net.Addr
// LocalPeerID is the local peer id of the connection.
//返回本地节点id
LocalPeerID() peer.ID
// RemoteAddr is the remote net multi-address of the connection.
//返回远程地址
RemoteAddr() ma.Multiaddr
// RemoteNetAddr is the remote net address of the connection.
//返回远程网络地址
RemoteNetAddr() net.Addr
// RemotePeerID is the remote peer id of the connection.
//返回远程节点id
RemotePeerID() peer.ID
// Network is the network instance who create this connection.
//返回创建连接的网络
Network() Network
// CreateSendStream try to open a sending stream with the connection.
//打开发送流
CreateSendStream() (SendStream, error)
// AcceptReceiveStream accept a receiving stream with the connection.
// It will block until a new receiving stream accepted or connection closed.
//从连接上接收流,直接接收到,直到连接关闭
AcceptReceiveStream() (ReceiveStream, error)
// CreateBidirectionalStream try to open a bidirectional stream with the connection.
//打开一个bidirectional 流
CreateBidirectionalStream() (Stream, error)
// AcceptBidirectionalStream accept a bidirectional stream with the connection.
// It will block until a new bidirectional stream accepted or connection closed.
//接收链接上的流,直接接收到,或者连接关闭
AcceptBidirectionalStream() (Stream, error)
}
复制代码
划线
评论
复制
发布于: 刚刚阅读数: 4
李
关注
还未添加个人签名 2018-05-04 加入
还未添加个人简介
评论