In file framesend.hh:

namespace diag class frameSend

Class for broadcasting frame data

Inheritance:


Public Methods

explicit frameSend (int maxBuffers = sndDefaultBuffers)
Default constructor.
explicit frameSend (const char* addr, const char* interface = 0, int port = frameXmitPort, int maxBuffers = sndDefaultBuffers)
Constructor.
~frameSend ()
Destructor.
bool open (const char* addr, const char* interface = 0, int port = frameXmitPort)
Open function.
bool open (int port = frameXmitPort)
Open function.
void close ()
Close function.
bool send (char* data, int len, bool* inUse = 0, bool copy = false, unsigned int timestamp = 0, unsigned int duration = 0)
Send function.
int skipped () const
Skip function.
bool isUsed (bool& inUse) const
isUsed function.

Documentation

Class for broadcasting frame data. This class implements the broadcast transmitter. A code example can be found in 'sndtest.cc'.

explicit frameSend(int maxBuffers = sndDefaultBuffers)
Constructs a default broadcast transmitter.
Returns:
void
Parameters:
maxBuffers - maximum number of used buffers

explicit frameSend(const char* addr, const char* interface = 0, int port = frameXmitPort, int maxBuffers = sndDefaultBuffers)
Constructs a broadcast/multicast transmitter and connects it.
Returns:
void
Parameters:
addr - broadcast address/multicast group
interface - interface or subnet used by multicast
port - port number
maxBuffers - maximum number of used buffers

~frameSend()
Denstructs the broadcast transmitter.
Returns:
void

bool open(const char* addr, const char* interface = 0, int port = frameXmitPort)
Opens the conenction. If the specified addr is a multicast address, the transmitter will use UDP/IP multicast rather than UDP/IP broadcast. If multicast is used, an additional parameter specifes the interface which will be used. If the interface is obmitted, the default interface will be used. In general, one can use the subnet address as the interface address argument. The function will then go through the list of all local interfaces and determine the closest match.
Returns:
true if successful
Parameters:
addr - broadcast address
interface - interface or subnet used by multicast
port - port number

bool open(int port = frameXmitPort)
Opens the conenction. Uses UDP/IP broadcast.
Returns:
true if successful
Parameters:
port - port number

void close()
Closes the conenction.
Returns:
void

bool send(char* data, int len, bool* inUse = 0, bool copy = false, unsigned int timestamp = 0, unsigned int duration = 0)
Broadcast a data buffer. This function will not block and return immediately. To assure that the data array stays valid until after it is transmitted, the caller can either request that the data array is copied, or supply a pointer to a boolean 'inUse' variable which will be set false by the transmitter after the buffer has been sent. The inUse variable should never be accessed directly, but rather through 'isUsed' function only.

The send fucntion works as follows:

1. The send function will NOT transmit the buffer by itself but rather put the buffer into a queue which is then managed by the xmitdaemon.

2. The send function will always return immediately and will NOT block until the buffer is sent.

3. If the buffer queue is full, the send function will remove all unsent buffers from it.

4. After a buffer is sent, it will stay in the queue for an additional time period (~3 sec) to allow retransmit. Then it will automatically be released.

5. There are basically two ways to deal with the problem of how long data in a buffer must be kept:

a. The send function copies the buffer (avoids buffer validity problems all together), or

b. The send function does not copy the buffer and the caller must keep the buffer valid until the xmitdaemon is done with it.

In the second case the caller MUST NOT delete or change the data in the buffer until it is no longer needed. To verify if the buffer is still in use, the caller can check the 'inUse' variable with th ehelp of the isUsed method.

Returns:
true if successful
Parameters:
data - data array
len - length of data array (in bytes)
inUse - pointer to in use variable (ignored if 0)
copy - request a copy of the data to be used
timestamp - time stamp of data array
duration - time length of data array

int skipped() const
Returns the total number of skipped output buffers.
Returns:
skipped buffers

bool isUsed(bool& inUse) const
Returns true if variable is in use (MT safe).
Returns:
in use value
Parameters:
inUse - in use variable to be read

buffer()
construct default buffer

buffer(const buffer& buf)
copy constructor

buffer(char* Data, int Len, unsigned int Seq, bool Own = false, bool* Used = 0, mutex* InUseMux = 0, unsigned int Timestamp = 0, unsigned int Duration = 0)
constructs a data buffer

~buffer()
destructs the buffer

buffer& operator= (const buffer& buf)
asignment operator

unsigned int seq
buffer sequence number

mutable bool own
buffer owns the data

char* data
data pointer

int len
length of data array

mutable bool* used
pointer to in use variable

mutex* inUseMux
in use mutex

unsigned int timestamp
time stamp

unsigned int duration
duration

int sofar
transferred so far


This class has no child classes.
Author:
Written August 1999 by Daniel Sigg
Version:
2.0

alphabetic index hierarchy of classes


Please send questions and comments to sigg_d@ligo-wa.caltech.edu


generated by doc++