Add address methods to Conn
This commit is contained in:
parent
19fa5983d6
commit
f0753c5113
@ -1,19 +1,38 @@
|
|||||||
package hopp
|
package hopp
|
||||||
|
|
||||||
import "io"
|
import "net"
|
||||||
|
// import "time"
|
||||||
|
|
||||||
// Conn is a HOPP connection.
|
// Conn is a HOPP connection.
|
||||||
type Conn interface {
|
type Conn interface {
|
||||||
io.Closer
|
// Close closes the connection. Any blocked operations on the connection
|
||||||
|
// or its transactions will be unblocked and return errors.
|
||||||
|
Close() error
|
||||||
|
|
||||||
|
// See documentation for [net.Conn]
|
||||||
|
LocalAddr() net.Addr
|
||||||
|
RemoteAddr() net.Addr
|
||||||
|
|
||||||
|
// OpenTrans opens a transaction. The other party will not know about
|
||||||
|
// this until the first message is sent.
|
||||||
OpenTrans() (Trans, error)
|
OpenTrans() (Trans, error)
|
||||||
|
// AcceptTrans accepts a transaction from the other party. This must
|
||||||
|
// be called in a loop to avoid the connection locking up.
|
||||||
AcceptTrans() (Trans, error)
|
AcceptTrans() (Trans, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trans is a HOPP transaction.
|
// Trans is a HOPP transaction.
|
||||||
type Trans interface {
|
type Trans interface {
|
||||||
io.Closer
|
// Close closes the transaction. Any blocked operations will be
|
||||||
|
// unblocked and return errors.
|
||||||
|
Close() error
|
||||||
|
|
||||||
|
// ID returns the transaction ID. This must not change, and it must be
|
||||||
|
// unique within the connection.
|
||||||
ID() int64
|
ID() int64
|
||||||
|
|
||||||
|
// TODO: add methods for setting send and receive deadlines
|
||||||
|
|
||||||
// Send sends a message.
|
// Send sends a message.
|
||||||
Send(method uint16, data []byte) error
|
Send(method uint16, data []byte) error
|
||||||
// Receive receives a message.
|
// Receive receives a message.
|
||||||
|
Loading…
Reference in New Issue
Block a user