Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Wireless Class Reference

#include <Wireless.h>

List of all members.


Detailed Description

Tekkotsu wireless class.

For more information on using wireless, please read the following tutorials:

The networking interface needs more documentation. It also needs a cleanup. In the mean time, take a look at the TekkotsuMon objects in Tekkotsu/Behaviors/Mon. They all listen for new connections. Unfortunately, at the momement there are no examples of outgoing connections, but it should give you a pretty good idea how to start moving.

Definition at line 35 of file Wireless.h.

ResourcecallbackLock
 this lock will be aquired during any callbacks which might occur during pollProcess()
int interruptChk
 a socket, connected to interruptCtl, which allows pollTest() to be interrupted if new sockets need to be polled
int interruptCtl
 a socket, connected to interruptChk, which allows pollTest() to be interrupted if new sockets need to be polled
fd_set rfds
 a set of file descriptors which should be polled for readable data; set up by pollSetup(), watched (blocking) by pollTest(), and processed by pollProcess()
fd_set wfds
 a set of file descriptors which should be polled for write-complete; set up by pollSetup(), watched (blocking) by pollTest(), and processed by pollProcess()
fd_set efds
 a set of file descriptors which should be polled for errors; set up by pollSetup(), watched (blocking) by pollTest(), and processed by pollProcess()
int fdsMax
 maximum file descriptor value in the rfds, wfds, efds fd_set's
Socketsockets [WIRELESS_MAX_SOCKETS]
 this lock will be aquired during any callbacks which might occur during pollProcess()
std::list< int > freeSockets
 this lock will be aquired during any callbacks which might occur during pollProcess()
std::list< int > usedSockets
 this lock will be aquired during any callbacks which might occur during pollProcess()
static ResourcegetLock ()
 private ALOKL_TODO

Public Member Functions

 Wireless ()
 constructor - only one wireless object is required per Aperios process.
 ~Wireless ()
 destructor
int listen (int sock, int port)
 The socket waits for incoming connections.
int connect (int sock, const char *ipaddr, int port)
 The socket tries to connect to a specific.
void setReceiver (int sock, int(*rcvcbckfn)(char *, int))
 sets receiver callback for a socket
void setReceiver (int sock, SocketListener *listener)
 sets receiver callback for a socket, this version requiring the SocketListener interface (more powerful, as this lets us tell connections apart)
void setDaemon (int sock, bool val=true)
 sets the socket to be a daemon (recycles on close)
bool getDaemon (int sock)
 sets the socket to be a daemon (recycles on close)
void close (int sock)
 closes and destroys non server, daemon sockets
void pollSetup ()
 on non-aperios, set up structures to be checked in pollTest()
bool pollTest (struct timeval *tv)
 on non-aperios, check to see any network communication has occurred
void pollProcess ()
 on non-aperios, process callbacks and state changes as signaled in pollTest()
void wakeup (Socket *del=NULL)
 writes del on interruptCtl, breaking out of a pending pollTest() and thus giving an opportunity to change the contents of the FD sets being used;
void setCallbackLock (Resource &l)
 sets callbackLock
void clearCallbackLock ()
 resets callbackLock to a self-defined lock, which you can request from getCallbackLock() (there's always a callbackLock, the only question is it internally or externally instantiated)
ResourcegetCallbackLock () const
 returns callbackLock
Socketsocket (Socket::TransportType_t ttype)
 Creates a new socket.
Socketsocket (Socket::TransportType_t ttype, int recvsize, int sendsize)
bool isConnected (int sock)
 utility function that you can use if you're curious about the state of the socket.
bool isError (int sock)
 utility function that you can use if you're curious about the state of the socket.
bool isReady (int sock)
 utility function that you can use if you're curious about the state of the socket.
bool hasData (int sock)
 utility function that you can use if you're curious about the state of the socket.
void setReceiver (Socket &sobj, int(*rcvcbckfn)(char *, int))
 helper function for the function with the same name that takes a socket descriptor (int)
void setReceiver (Socket *sobj, int(*rcvcbckfn)(char *, int))
 helper function for the function with the same name that takes a socket descriptor (int)
void setReceiver (Socket &sobj, SocketListener *listener)
 helper function for the function with the same name that takes a socket descriptor (int)
void setReceiver (Socket *sobj, SocketListener *listener)
 helper function for the function with the same name that takes a socket descriptor (int)
void setDaemon (Socket &sobj, bool val=true)
 helper function for the function with the same name that takes a socket descriptor (int)
void setDaemon (Socket *sobj, bool val=true)
 helper function for the function with the same name that takes a socket descriptor (int)
bool getDaemon (Socket &sobj)
 helper function for the function with the same name that takes a socket descriptor (int)
bool getDaemon (Socket *sobj)
 helper function for the function with the same name that takes a socket descriptor (int)
int listen (Socket &sobj, int port)
 helper function for the function with the same name that takes a socket descriptor (int)
int listen (Socket *sobj, int port)
 helper function for the function with the same name that takes a socket descriptor (int)
int connect (Socket &sobj, const char *ipaddr, int port)
 helper function for the function with the same name that takes a socket descriptor (int)
int connect (Socket *sobj, const char *ipaddr, int port)
 helper function for the function with the same name that takes a socket descriptor (int)
void close (Socket &sobj)
 helper function for the function with the same name that takes a socket descriptor (int)
void close (Socket *sobj)
 helper function for the function with the same name that takes a socket descriptor (int)
unsigned int getNumInterfaces ()
 helper function for the function with the same name that takes a socket descriptor (int)
uint32 getIPAddress (unsigned int idx=0)
void receive (int sock, int(*rcvcbckfn)(char *, int))
 function for internal and Socket use. You should not call this
void receive (int sock)
 function for internal and Socket use. You should not call this
void send (int sock)
void blockingSend (int sock)

Static Public Attributes

static const int WIRELESS_MAX_SOCKETS = 100
 Maximum number of sockets which can be created.
static const int WIRELESS_DEF_RECV_SIZE = 1024
 Default number of bytes to use for receive buffers (overridden by value passed to socket()).
static const int WIRELESS_DEF_SEND_SIZE = 1024
 Default number of bytes to use for send buffers (overridden by value passed to socket()).

Static Protected Attributes

static const int MAXCONNECTIONS = 5
 the maximum number of connections which can be queued when listening

Private Member Functions

 Wireless (const Wireless &)
 don't call
Wirelessoperator= (const Wireless &)
 don't call

Friends

class Socket

Constructor & Destructor Documentation

Wireless::Wireless (  ) 

constructor - only one wireless object is required per Aperios process.

MMCombo already creates one. The (global) instance is called wireless, and you can access it by including Wireless/Wireless.h (this file) in your code

Definition at line 635 of file Wireless.cc.

Wireless::~Wireless (  ) 

destructor

Definition at line 657 of file Wireless.cc.

Wireless::Wireless ( const Wireless  )  [private]

don't call


Member Function Documentation

Socket * Wireless::socket ( Socket::TransportType_t  ttype,
int  recvsize,
int  sendsize 
)

Parameters:
ttype selects between TCP and UDP
recvsize size of input buffer
sendsize size of output buffer

Definition at line 793 of file Wireless.cc.

int Wireless::connect ( int  sock,
const char *  ipaddr,
int  port 
)

The socket tries to connect to a specific.

Definition at line 712 of file Wireless.cc.

Referenced by connect(), RemoteRouter::connect(), EchoBehavior::processCallback(), and EchoBehavior::processEvent().

void Wireless::setReceiver ( int  sock,
SocketListener listener 
)

sets receiver callback for a socket, this version requiring the SocketListener interface (more powerful, as this lets us tell connections apart)

Definition at line 679 of file Wireless.cc.

bool Wireless::getDaemon ( int  sock  )  [inline]

sets the socket to be a daemon (recycles on close)

Definition at line 86 of file Wireless.h.

Referenced by getDaemon().

bool Wireless::isError ( int  sock  )  [inline]

utility function that you can use if you're curious about the state of the socket.

You shouldn't need to use it, since asking sockets for write and read buffers does the necessary sanity checks

Definition at line 98 of file Wireless.h.

bool Wireless::isReady ( int  sock  )  [inline]

utility function that you can use if you're curious about the state of the socket.

You shouldn't need to use it, since asking sockets for write and read buffers does the necessary sanity checks

Definition at line 102 of file Wireless.h.

bool Wireless::hasData ( int  sock  )  [inline]

utility function that you can use if you're curious about the state of the socket.

You shouldn't need to use it, since asking sockets for write and read buffers does the necessary sanity checks

Definition at line 103 of file Wireless.h.

void Wireless::setReceiver ( Socket sobj,
int(*)(char *, int)  rcvcbckfn 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 108 of file Wireless.h.

void Wireless::setReceiver ( Socket sobj,
int(*)(char *, int)  rcvcbckfn 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 110 of file Wireless.h.

void Wireless::setReceiver ( Socket sobj,
SocketListener listener 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 112 of file Wireless.h.

void Wireless::setReceiver ( Socket sobj,
SocketListener listener 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 114 of file Wireless.h.

void Wireless::setDaemon ( Socket sobj,
bool  val = true 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 116 of file Wireless.h.

void Wireless::setDaemon ( Socket sobj,
bool  val = true 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 117 of file Wireless.h.

bool Wireless::getDaemon ( Socket sobj  )  [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 118 of file Wireless.h.

bool Wireless::getDaemon ( Socket sobj  )  [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 119 of file Wireless.h.

int Wireless::listen ( Socket sobj,
int  port 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 120 of file Wireless.h.

int Wireless::listen ( Socket sobj,
int  port 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 121 of file Wireless.h.

int Wireless::connect ( Socket sobj,
const char *  ipaddr,
int  port 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 122 of file Wireless.h.

int Wireless::connect ( Socket sobj,
const char *  ipaddr,
int  port 
) [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 124 of file Wireless.h.

void Wireless::close ( Socket sobj  )  [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 126 of file Wireless.h.

void Wireless::close ( Socket sobj  )  [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 127 of file Wireless.h.

unsigned int Wireless::getNumInterfaces (  )  [inline]

helper function for the function with the same name that takes a socket descriptor (int)

Definition at line 128 of file Wireless.h.

uint32 Wireless::getIPAddress ( unsigned int  idx = 0  ) 

There's probably better ways to implement this... (run through the interface list? How does ifconfig do it?)

Definition at line 820 of file Wireless.cc.

void Wireless::receive ( int  sock,
int(*)(char *, int)  rcvcbckfn 
)

function for internal and Socket use. You should not call this

void Wireless::receive ( int  sock  ) 

function for internal and Socket use. You should not call this

void Wireless::send ( int  sock  ) 

function called by the Socket objects to actually write data to the network. You should not call this.

Definition at line 840 of file Wireless.cc.

Referenced by blockingSend(), and Socket::flush().

void Wireless::blockingSend ( int  sock  ) 

function called by the Socket objects to actually write data to the network. You should not call this.

Definition at line 875 of file Wireless.cc.

Referenced by Socket::flush().

void Wireless::pollSetup (  ) 

on non-aperios, set up structures to be checked in pollTest()

Definition at line 911 of file Wireless.cc.

bool Wireless::pollTest ( struct timeval *  tv  ) 

on non-aperios, check to see any network communication has occurred

Parameters:
tv how long to wait -- NULL will wait indefinitely until a socket event occurs
Returns:
true if there was a socket event to process, false if timed out

Definition at line 941 of file Wireless.cc.

void Wireless::pollProcess (  ) 

on non-aperios, process callbacks and state changes as signaled in pollTest()

Definition at line 948 of file Wireless.cc.

void Wireless::wakeup ( Socket del = NULL  ) 

writes del on interruptCtl, breaking out of a pending pollTest() and thus giving an opportunity to change the contents of the FD sets being used;

Parameters:
del if non-NULL, will cause the socket to be closed and deleted

Definition at line 1150 of file Wireless.cc.

Referenced by send().

void Wireless::setCallbackLock ( Resource l  ) 

sets callbackLock

Definition at line 1159 of file Wireless.cc.

void Wireless::clearCallbackLock (  ) 

resets callbackLock to a self-defined lock, which you can request from getCallbackLock() (there's always a callbackLock, the only question is it internally or externally instantiated)

Definition at line 1164 of file Wireless.cc.

Resource& Wireless::getCallbackLock (  )  const [inline]

returns callbackLock

Definition at line 165 of file Wireless.h.

Resource & Wireless::getLock (  )  [static, protected]

private ALOKL_TODO

returns the lock to use during all wireless operations (not just callbacks, this is more general)

Definition at line 1154 of file Wireless.cc.

Referenced by blockingSend(), Socket::flush(), Socket::getWriteBuffer(), Socket::init(), send(), Socket::vprintf(), and Socket::write().

Wireless& Wireless::operator= ( const Wireless  )  [private]

don't call


Friends And Related Function Documentation

friend class Socket [friend]

Definition at line 169 of file Wireless.h.


Member Data Documentation

const int Wireless::WIRELESS_MAX_SOCKETS = 100 [static]

Maximum number of sockets which can be created.

Definition at line 38 of file Wireless.h.

Referenced by blockingSend(), send(), and Wireless().

const int Wireless::WIRELESS_DEF_RECV_SIZE = 1024 [static]

Default number of bytes to use for receive buffers (overridden by value passed to socket()).

Definition at line 41 of file Wireless.h.

const int Wireless::WIRELESS_DEF_SEND_SIZE = 1024 [static]

Default number of bytes to use for send buffers (overridden by value passed to socket()).

Definition at line 44 of file Wireless.h.

const int Wireless::MAXCONNECTIONS = 5 [static, protected]

the maximum number of connections which can be queued when listening

Definition at line 170 of file Wireless.h.

this lock will be aquired during any callbacks which might occur during pollProcess()

Definition at line 179 of file Wireless.h.

Referenced by getCallbackLock().

int Wireless::interruptChk [protected]

a socket, connected to interruptCtl, which allows pollTest() to be interrupted if new sockets need to be polled

Definition at line 180 of file Wireless.h.

Referenced by Wireless().

int Wireless::interruptCtl [protected]

a socket, connected to interruptChk, which allows pollTest() to be interrupted if new sockets need to be polled

Definition at line 181 of file Wireless.h.

Referenced by wakeup(), and Wireless().

fd_set Wireless::rfds [protected]

a set of file descriptors which should be polled for readable data; set up by pollSetup(), watched (blocking) by pollTest(), and processed by pollProcess()

Definition at line 182 of file Wireless.h.

Referenced by pollTest(), and Wireless().

fd_set Wireless::wfds [protected]

a set of file descriptors which should be polled for write-complete; set up by pollSetup(), watched (blocking) by pollTest(), and processed by pollProcess()

Definition at line 183 of file Wireless.h.

Referenced by pollTest(), and Wireless().

fd_set Wireless::efds [protected]

a set of file descriptors which should be polled for errors; set up by pollSetup(), watched (blocking) by pollTest(), and processed by pollProcess()

Definition at line 184 of file Wireless.h.

Referenced by pollTest(), and Wireless().

int Wireless::fdsMax [protected]

maximum file descriptor value in the rfds, wfds, efds fd_set's

Definition at line 185 of file Wireless.h.

Referenced by pollTest(), and Wireless().

this lock will be aquired during any callbacks which might occur during pollProcess()

Definition at line 187 of file Wireless.h.

Referenced by getDaemon(), hasData(), isConnected(), isError(), isReady(), setDaemon(), and Wireless().

std::list<int> Wireless::freeSockets [protected]

this lock will be aquired during any callbacks which might occur during pollProcess()

Definition at line 188 of file Wireless.h.

Referenced by Wireless().

std::list<int> Wireless::usedSockets [protected]

this lock will be aquired during any callbacks which might occur during pollProcess()

Definition at line 189 of file Wireless.h.


The documentation for this class was generated from the following files:

Tekkotsu v4.0
Generated Thu Nov 22 00:58:48 2007 by Doxygen 1.5.4