...

Package connection

import "vminko.org/dscuss/p2p/connection"
Overview
Index

Overview ▾

Constants

const (
    DefaultTimeout time.Duration = 1 * time.Second
    // Limits the size of a packet. Anything larger will cause
    // a decoding error.
    MaxPacketSize int = 10 * 1024
)

type Connection

Connection is responsible for transferring packets via the network.

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

func New

func New(conn net.Conn, isIncoming bool) *Connection

func (*Connection) AddAddresses

func (c *Connection) AddAddresses(new []string)

func (*Connection) Addresses

func (c *Connection) Addresses() []string

Addresses returns a copy of address list associated with the connection.

func (*Connection) ClearAddresses

func (c *Connection) ClearAddresses()

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) IsActive

func (c *Connection) IsActive() bool

func (*Connection) IsIncoming

func (c *Connection) IsIncoming() bool

func (*Connection) LocalAddr

func (c *Connection) LocalAddr() string

func (*Connection) Read

func (c *Connection) Read() (*packet.Packet, error)

func (*Connection) ReadFull

func (c *Connection) ReadFull(timeout time.Duration) (*packet.Packet, error)

func (*Connection) RegisterCloseHandler

func (c *Connection) RegisterCloseHandler(f func(*Connection))

func (*Connection) RemoteAddr

func (c *Connection) RemoteAddr() string

func (*Connection) String

func (c *Connection) String() string

func (*Connection) Write

func (c *Connection) Write(p *packet.Packet) error

func (*Connection) WriteFull

func (c *Connection) WriteFull(p *packet.Packet, timeout time.Duration) error