lspnet

package
Version: v0.0.0-...-f5d73c0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableDebugLogs

func EnableDebugLogs(enable bool)

EnableDebugLogs has log messages directed to standard output if enable is true.

func JoinHostPort

func JoinHostPort(host, port string) string

JoinHostPort behaves the same as the net.JoinHostPort function.

func ResetDropPercent

func ResetDropPercent()

ResetDropPercent resets all drop percents to 0.

func SetClientReadDropPercent

func SetClientReadDropPercent(p int)

SetClientReadDropPercent sets the read drop percent for clients.

func SetClientWriteDropPercent

func SetClientWriteDropPercent(p int)

SetClientWriteDropPercent sets the write drop percent for clients.

func SetMsgLengtheningPercent

func SetMsgLengtheningPercent(p int)

SetMsgLengtheningPercent sets the message lengthening percentfor clients and servers.

func SetMsgShorteningPercent

func SetMsgShorteningPercent(p int)

SetMsgShorteningPercent sets the message shortening percent for clients and servers.

func SetReadDropPercent

func SetReadDropPercent(p int)

SetReadDropPercent sets the read drop percent for both clients and servers.

func SetServerReadDropPercent

func SetServerReadDropPercent(p int)

SetServerReadDropPercent sets the read drop percent for servers.

func SetServerWriteDropPercent

func SetServerWriteDropPercent(p int)

SetServerWriteDropPercent sets the write drop percent for servers.

func SetWriteDropPercent

func SetWriteDropPercent(p int)

SetWriteDropPercent sets the write drop percent for clients and servers.

func SplitHostPort

func SplitHostPort(hostport string) (host, port string, err error)

SplitHostPort behaves the same as the net.SplitHostPort function.

Types

type TemporaryMessage

type TemporaryMessage struct {
	Type    int
	ConnID  int
	SeqNum  int
	Size    int
	Payload []byte
}

This really shouldn't be here as it is a break of abstraction, but it is a minor hack to vary the payload length.

type UDPAddr

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

UDPAddr is a wrapper around net.UDPAddr.

func ResolveUDPAddr

func ResolveUDPAddr(ntwk, addr string) (*UDPAddr, error)

ResolveUDPAddr behaves the same as the net.UDPAddr.ResolveUDPAddr method (with some additional book-keeping).

func (*UDPAddr) String

func (a *UDPAddr) String() string

type UDPConn

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

UDPConn is a wrapper around net.UDPConn. Method invocations are for the most part proxied directly to the corresponding methods in the net.UDPConn packge, but provide some additional book-keeping that is necessary for testing the students' code.

func DialUDP

func DialUDP(ntwk string, laddr, raddr *UDPAddr) (*UDPConn, error)

DialUDP behaves the same as the net.DialUDP method (with some additional book-keeping).

Clients should use this method to connect to the server.

func ListenUDP

func ListenUDP(ntwk string, laddr *UDPAddr) (*UDPConn, error)

ListenUDP behaves the same as the net.ListenUDP method (with some additional book-keeping).

Servers should use this method to begin listening for incoming client connections.

func (*UDPConn) Close

func (c *UDPConn) Close() error

Close closes the connection.

func (*UDPConn) Read

func (c *UDPConn) Read(b []byte) (n int, err error)

Read implements the Conn Read method.

func (*UDPConn) ReadFromUDP

func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err error)

ReadFromUDP reads a UDP packet from c, copying the payload into b. It returns the number of bytes copied into b and the return address that was on the packet.

func (*UDPConn) Write

func (c *UDPConn) Write(b []byte) (int, error)

Write implements the Conn Write method.

func (*UDPConn) WriteToUDP

func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error)

WriteToUDP writes a UDP packet to addr via c, copying the payload from b.

Jump to

Keyboard shortcuts

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