client

package
v0.0.0-...-c3fa490 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Conn     net.Conn
	Choked   bool
	Bitfield bitfield.Bitfield
	// contains filtered or unexported fields
}

A Client is a TCP connection with a peer

func New

func New(peer peers.Peer, peerID, infoHash [20]byte) (*Client, error)

New connects with a peer, completes a handshake, and receives a handshake returns an err if any of those fail.

func (*Client) Read

func (c *Client) Read() (*message.Message, error)

Read reads and consumes a message from the connection

func (*Client) SendHave

func (c *Client) SendHave(index int) error

SendHave sends a Have message to the peer

func (*Client) SendInterested

func (c *Client) SendInterested() error

SendInterested sends an Interested message to the peer

func (*Client) SendNotInterested

func (c *Client) SendNotInterested() error

SendNotInterested sends a NotInterested message to the peer

func (*Client) SendRequest

func (c *Client) SendRequest(index, begin, length int) error

SendRequest sends a Request message to the peer

func (*Client) SendUnchoke

func (c *Client) SendUnchoke() error

SendUnchoke sends an Unchoke message to the peer

Jump to

Keyboard shortcuts

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