peerconn

package
v0.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is a peer connection that provides a channel for receiving messages and methods for sending messages.

func New

func New(conn net.Conn, l logger.Logger, pieceTimeout time.Duration, maxRequestsIn int, fastEnabled bool) *Conn

func (*Conn) Addr

func (p *Conn) Addr() *net.TCPAddr

func (*Conn) CancelRequest

func (p *Conn) CancelRequest(msg peerprotocol.CancelMessage)

CancelRequest removes previously queued piece message matching msg.

func (*Conn) Close

func (p *Conn) Close()

Close stops receiving and sending messages and closes underlying net.Conn.

func (*Conn) IP

func (p *Conn) IP() string

func (*Conn) Logger

func (p *Conn) Logger() logger.Logger

func (*Conn) Messages

func (p *Conn) Messages() <-chan interface{}

Messages received from the peer will be sent to the channel returned. The channel and underlying net.Conn will be closed if any error occurs while receiving or sending.

func (*Conn) Run

func (p *Conn) Run()

Run starts receiving messages from peer and starts sending queued messages. If any error happens during receiving or sending messages, the connection and the underlying net.Conn will be closed.

func (*Conn) SendMessage

func (p *Conn) SendMessage(msg peerprotocol.Message)

SendMessage queues a message for sending. Does not block.

func (*Conn) SendPiece

func (p *Conn) SendPiece(msg peerprotocol.RequestMessage, pi io.ReaderAt)

SendPiece queues a piece message for sending. Does not block. Piece data is read just before the message is sent. If queued messages greater than `maxRequestsIn` specified in constructor, the last message is dropped.

func (*Conn) String

func (p *Conn) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL