Documentation ¶
Index ¶
- func DialTCP(addr string, he *proto.HostingEnv) (po *proto.PostingEnd, ho *proto.HostingEnd, err error)
- func DialUnix(addr string, he *proto.HostingEnv) (po *proto.PostingEnd, ho *proto.HostingEnd, err error)
- func ServeTCP(addr string, heFactory func() *proto.HostingEnv, ...) (err error)
- func ServeUnix(addr string, heFactory func() *proto.HostingEnv, cb func(*net.UnixListener)) (err error)
- func TakeConn(conn net.Conn, he *proto.HostingEnv) (po *proto.PostingEnd, ho *proto.HostingEnd, err error)
- func TakeSocket(fd int, he *proto.HostingEnv) (po *proto.PostingEnd, ho *proto.HostingEnd, err error)
- type SocketWire
- func (wire *SocketWire) Disconnect()
- func (wire *SocketWire) LocalAddr() string
- func (wire *SocketWire) NetIdent() string
- func (wire *SocketWire) RecvData(d []byte) (n int64, err error)
- func (wire *SocketWire) RecvPacket() (packet *proto.Packet, err error)
- func (wire *SocketWire) RecvStream(ds func() ([]byte, error)) (n int64, err error)
- func (wire *SocketWire) RemoteAddr() string
- func (wire *SocketWire) SendData(d []byte) (n int64, err error)
- func (wire *SocketWire) SendPacket(payload, wireDir string) (n int64, err error)
- func (wire *SocketWire) SendStream(ds func() ([]byte, error)) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DialTCP ¶
func DialTCP(addr string, he *proto.HostingEnv) (po *proto.PostingEnd, ho *proto.HostingEnd, err error)
DialTCP connects to specified remote address (host:port), react with specified hosting environment.
The returned posting endpoint is used to create posting conversations to send code & data to remote site for active communication.
The returned hosting endpoint is used to obtain the current hosting conversation triggered by a posting conversation from remote site for passive communication.
func DialUnix ¶
func DialUnix(addr string, he *proto.HostingEnv) (po *proto.PostingEnd, ho *proto.HostingEnd, err error)
DialUnix connects to specified file path (domain socket), react with specified hosting environment.
The returned posting endpoint is used to create posting conversations to send code & data to remote site for active communication.
The returned hosting endpoint is used to obtain the current hosting conversation triggered by a posting conversation from remote site for passive communication.
func ServeTCP ¶
func ServeTCP(addr string, heFactory func() *proto.HostingEnv, cb func(*net.TCPListener) error) (err error)
ServeTCP listens on the specified local address (host:port), serves each incoming connection with a hosting environment produced by the `heFactory` function.
`cb` will be called with the created `*net.TCPListener`, it's handful to specify port as 0, and receive the actual port from the cb.
This func won't return until the listener is closed.
func ServeUnix ¶
func ServeUnix(addr string, heFactory func() *proto.HostingEnv, cb func(*net.UnixListener)) (err error)
ServeUnix listens on the specified file path (domain socket), serves each incoming connection with the hosting environment created from the `heFactory` function.
`cb` will be called with the created `*net.UnixListener`.
This func won't return until the listener is closed.
func TakeConn ¶
func TakeConn(conn net.Conn, he *proto.HostingEnv) ( po *proto.PostingEnd, ho *proto.HostingEnd, err error)
TakeConn takes a pre-connected connection (Unix or TCP), react with specified hosting environment.
The returned posting endpoint is used to create posting conversations to send code & data to remote site for active communication.
The returned hosting endpoint is used to obtain the current hosting conversation triggered by a posting conversation from remote site for passive communication.
func TakeSocket ¶
func TakeSocket(fd int, he *proto.HostingEnv) ( po *proto.PostingEnd, ho *proto.HostingEnd, err error)
TakeSocket takes a pre-connected socket (Unix or TCP), react with specified hosting environment.
The returned posting endpoint is used to create posting conversations to send code & data to remote site for active communication.
The returned hosting endpoint is used to obtain the current hosting conversation triggered by a posting conversation from remote site for passive communication.
Types ¶
type SocketWire ¶
type SocketWire struct {
// contains filtered or unexported fields
}
SocketWire is HBI wire protocol over a plain Sock socket.
func NewSocketWire ¶
func NewSocketWire(conn net.Conn) *SocketWire
NewSocketWire creates a new HBI wire over a socket channel
func (*SocketWire) Disconnect ¶
func (wire *SocketWire) Disconnect()
Disconnect disconnects the underlying socket
func (*SocketWire) LocalAddr ¶
func (wire *SocketWire) LocalAddr() string
LocalAddr returns a string for local address of the underlying socket
func (*SocketWire) NetIdent ¶
func (wire *SocketWire) NetIdent() string
NetIdent returns a string to identify the underlying socket
func (*SocketWire) RecvData ¶
func (wire *SocketWire) RecvData(d []byte) (n int64, err error)
RecvData receives binary data into len() of `buf` from the specified channel, regardless of its cap().
func (*SocketWire) RecvPacket ¶
func (wire *SocketWire) RecvPacket() (packet *proto.Packet, err error)
RecvPacket receives next packet from peer endpoint.
func (*SocketWire) RecvStream ¶
func (wire *SocketWire) RecvStream(ds func() ([]byte, error)) (n int64, err error)
RecvStream receives binary data stream into all `[]byte` from the specified func. each []byte will be filled up to its len(), regardless of its cap().
func (*SocketWire) RemoteAddr ¶
func (wire *SocketWire) RemoteAddr() string
RemoteAddr returns a string for remote address of the underlying socket
func (*SocketWire) SendData ¶
func (wire *SocketWire) SendData(d []byte) (n int64, err error)
SendData will have len() of buf sent to peer endpoint, regardless of its cap()
func (*SocketWire) SendPacket ¶
func (wire *SocketWire) SendPacket(payload, wireDir string) (n int64, err error)
SendPacket sends a packet to peer endpoint.
func (*SocketWire) SendStream ¶
func (wire *SocketWire) SendStream(ds func() ([]byte, error)) (n int64, err error)
SendStream pulls all `[]byte` from the specified func and sends them as binary stream to peer endpoint. each `[]byte` will have its len() of data sent, regardless of its cap().