class UdpStack

classs implements a UDP transmitter AND a reciever

Public Methods

void addToFdSet( fd_set* set )
Add this stacks file descriptors to the the fdSet
bool checkIfSet( fd_set* set )
Check and see if this stacks file descriptor is set in fd_set
void connectPorts()
so that receive and send only from and to that remote port
void disconnectPorts()
disconnectPorts() dissolve the port association
void emulatePacketLoss( float probabilityOfLoss )
This can be used to eulate network packet loss by throwing out a certain percentage of the tranmitted packets
int getBytesReceived()
Get the number of bytes the stack has processed
int getBytesTransmitted()
Get the number of bytes the stack has processed
NetworkAddress* getDestinationHost()
int getDestinationPort()
Get the destination port
string getLclName()
Get the name for local
bool getLogFlag()
Get the udp stack logFlag
int getMaxFD( int prevMax = 0 )
Find the max of any file descripts in this stack and the passed value
UdpMode getMode()
Get the udp stack mode
int getPacketsReceived()
Get the number of datagrams the stack has processed
int getPacketsTransmitted()
Get the number of datagrams the stack has processed
string getRmtName()
Get the name for remote
int getRxPort()
Get the port being used for recieving
int getSocketFD()
Get the file descriptor for the socket - use with care or not at all
int getTxPort()
Get the port being used for transmitting
void joinMulticastGroup( NetworkAddress group, NetworkAddress* iface = NULL, int ifaceInexe = 0 )
void leaveMulticastGroup( NetworkAddress group, NetworkAddress* iface = NULL, int ifaceInexe = 0 )
int receive( const char* buffer, const int bufSize )
Once connectPorts() is called, can't receive from other ports
int receiveFrom( const char* buffer, const int bufSize, NetworkAddress* sender )
came from
int receiveTimeout( const char* buffer, const int bufSize, NetworkAddress* sender, int sec = 0, int usec = 0)
if successfull, -1 for error and 0 for timeout.
void setDestination( const NetworkAddress* host )
set the default destination
void setDestination( const char* host, int port )
set the default destination
void setLclName( const string& theName )
Set the name to something logical - only used for errors
void setLocal(const int minPort = -1, int maxPort = -1 )
set the local ports
void setLogFlag( const bool theLogFlag )
Set the logFlag
void setMode( const UdpMode theMode )
Set the mode
void transmit( const char* buffer, const int length )
ConnectPorts() should be called before it is called
int transmitTo( const char* buffer, const int length, const NetworkAddress* dest )
Transmit a datagram - use transmit if you always sent to the same person
UdpStack( const NetworkAddress* destinationHost = NULL, int localMinPort = -1, int localMaxPort = -1, UdpMode mode = sendrecv, bool log_flag = false, bool isMulticast = false)
no ports can be specified and the stack will pick one, OR a minPort can be specified and it will be used, OR a min and max can be specified and the stack will use the first free port in that range
virtual ~UdpStack()

Public

Recive a datagram into the specifed buffer - returns size of mesg.
Transmit a datagram
It is associate the local port to remote port
Recive a datagram into the specifed buffer - returns size of mesg.
connectPorts() has to be called before using send()
Use receive if you do not need to be able to tell who this packet
Recive a datagram into the specifed buffer - returns size of mesg.

Private Fields

UdpStackPrivateData* data
private data that will be a pain to port
string lclName
name of receiver
int localPort
port the stack is currently using
bool logFlag
flag for msg log
UdpMode mode
Mode
int numBytesReceived
number of bytes the stack has received
int numBytesTransmitted
number of bytes the stack has transimitted
int numPacketsReceived
number of datagrams the stack has received
int numPacketsTransmitted
number of datagrams the stack has transimitted
float packetLossProbability
probability of a given packet being thrown out by the stack
int remotePort
port the stack is currently using
string rmtName
name of transmitter

Private Methods

UdpStack& operator= ( const UdpStack& x )
Do not use
UdpStack( const UdpStack& )
Do not use

Documentation

classs implements a UDP transmitter AND a reciever
UdpStack( const NetworkAddress* destinationHost = NULL, int localMinPort = -1, int localMaxPort = -1, UdpMode mode = sendrecv, bool log_flag = false, bool isMulticast = false)
no ports can be specified and the stack will pick one, OR a minPort can be specified and it will be used, OR a min and max can be specified and the stack will use the first free port in that range. The destiantion hostname and port may be set in the destinationHost paramter *

connectPorts() has to be called before using send()

It is associate the local port to remote port

void connectPorts()
so that receive and send only from and to that remote port

void disconnectPorts()
disconnectPorts() dissolve the port association

void setLocal(const int minPort = -1, int maxPort = -1 )
set the local ports

void setDestination( const NetworkAddress* host )
set the default destination

void setDestination( const char* host, int port )
set the default destination

UdpMode getMode()
Get the udp stack mode

bool getLogFlag()
Get the udp stack logFlag

string getLclName()
Get the name for local

string getRmtName()
Get the name for remote

int getRxPort()
Get the port being used for recieving

int getTxPort()
Get the port being used for transmitting

int getDestinationPort()
Get the destination port

NetworkAddress* getDestinationHost()

void setMode( const UdpMode theMode )
Set the mode

void setLogFlag( const bool theLogFlag )
Set the logFlag

void setLclName( const string& theName )
Set the name to something logical - only used for errors

int getSocketFD()
Get the file descriptor for the socket - use with care or not at all

void addToFdSet( fd_set* set )
Add this stacks file descriptors to the the fdSet

int getMaxFD( int prevMax = 0 )
Find the max of any file descripts in this stack and the passed value

bool checkIfSet( fd_set* set )
Check and see if this stacks file descriptor is set in fd_set

Recive a datagram into the specifed buffer - returns size of mesg.

int receive( const char* buffer, const int bufSize )
Once connectPorts() is called, can't receive from other ports

Recive a datagram into the specifed buffer - returns size of mesg.

Use receive if you do not need to be able to tell who this packet

int receiveFrom( const char* buffer, const int bufSize, NetworkAddress* sender )
came from

Recive a datagram into the specifed buffer - returns size of mesg.

int receiveTimeout( const char* buffer, const int bufSize, NetworkAddress* sender, int sec = 0, int usec = 0)
if successfull, -1 for error and 0 for timeout.

Transmit a datagram

void transmit( const char* buffer, const int length )
ConnectPorts() should be called before it is called

int transmitTo( const char* buffer, const int length, const NetworkAddress* dest )
Transmit a datagram - use transmit if you always sent to the same person

void joinMulticastGroup( NetworkAddress group, NetworkAddress* iface = NULL, int ifaceInexe = 0 )

void leaveMulticastGroup( NetworkAddress group, NetworkAddress* iface = NULL, int ifaceInexe = 0 )

virtual ~UdpStack()

int getBytesTransmitted()
Get the number of bytes the stack has processed

int getPacketsTransmitted()
Get the number of datagrams the stack has processed

int getBytesReceived()
Get the number of bytes the stack has processed

int getPacketsReceived()
Get the number of datagrams the stack has processed

void emulatePacketLoss( float probabilityOfLoss )
This can be used to eulate network packet loss by throwing out a certain percentage of the tranmitted packets

UdpStack& operator= ( const UdpStack& x )
Do not use

UdpStack( const UdpStack& )
Do not use

int localPort
port the stack is currently using

int remotePort
port the stack is currently using

string lclName
name of receiver

string rmtName
name of transmitter

float packetLossProbability
probability of a given packet being thrown out by the stack

int numBytesReceived
number of bytes the stack has received

int numPacketsReceived
number of datagrams the stack has received

int numBytesTransmitted
number of bytes the stack has transimitted

int numPacketsTransmitted
number of datagrams the stack has transimitted

UdpMode mode
Mode

bool logFlag
flag for msg log

UdpStackPrivateData* data
private data that will be a pain to port


This class has no child classes.

alphabetic index hierarchy of classes


generated by doc++