...

Package connection

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

Overview ▾

Constants

const (
    Timeout time.Duration = 1 * time.Second
)

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) 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) 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