network

package
v0.0.0-...-b3da263 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2015 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LIST = iota
	LIST_REPLY
	FILE_REQUEST
	FILE_RESPONSE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdMessage

type CmdMessage struct {
	// control messaging
	Cmd    int
	Files  []fileManager.MyFile
	Source string

	// data messaging
	Hash                  string
	RequestedChunkNumbers []int
	ReturnedDataChunks    []DataTuple
	Size                  int
}

func Deserialize

func Deserialize(b []byte) CmdMessage

func NewCmdMessage

func NewCmdMessage() CmdMessage

func (CmdMessage) Serialize

func (m CmdMessage) Serialize() []byte

type DataTuple

type DataTuple struct {
	Position int
	Data     []byte
	Size     int
}

Higher level message

func NewDataTuple

func NewDataTuple(pos int, dat []byte, size int) DataTuple

type Message

type Message []byte

Lower level message

type Peer

type Peer struct {
	RecvCh chan Response
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(iface string) (*Peer, error)

func (*Peer) ListenMulticast

func (s *Peer) ListenMulticast()

func (*Peer) ListenUnicast

func (c *Peer) ListenUnicast()

func (*Peer) SendMulticast

func (c *Peer) SendMulticast(m Message)

multicast a query out

func (*Peer) SendUnicast

func (c *Peer) SendUnicast(m Message, to net.Addr)

unicast a query out

type Response

type Response struct {
	Msg  Message
	From net.Addr
}

Jump to

Keyboard shortcuts

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