Homepage Demos Overview Downloads Tutorials Reference
Credits

Socket Class Reference

#include <Socket.h>

Inheritance diagram for Socket:

Inheritance graph
[legend]
List of all members.

Detailed Description

Tekkotsu wireless Socket class.

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

Definition at line 47 of file Socket.h.

Public Member Functions

 Socket (int sockn)
 constructor

virtual ~Socket ()
 destructor

byte * getWriteBuffer (int bytesreq)
void write (int size)
 writes the specified number of bytes starting at the pointer returned.

int read ()
 Blocking read.

byte * getReadBuffer ()
 getReadBuffer is used with blocking read's

void init ()
 initialize socket member variables. This is different from the constructor since sockets are reused

int setFlushType (FlushType_t fType)
 Chooses between blocking and non-blocking input, output.

void setTextForward ()
 causes this socket to forward output to stdout if it is not connected, call setForward(NULL) to unset

void setForward (Socket *forsock)
 causes this socket to forward output to sock if it is not connected, pass NULL to unset

void setVerbosity (int verbose)
 Picks a level of verbosity for filtering pprintf commands.

int write (const byte *buf, int size)
int read (byte *buf, int size)
 Blocking read.

int printf (const char *fmt,...)
int vprintf (const char *fmt, va_list al)
int pprintf (int vlevel, const char *fmt,...)
 Similar to printf, except it takes an extra first argument.

void flush ()

Public Attributes

int sock
 unique non-negative integer representing socket. Serves as index into socket Objects array


Protected Member Functions

 Socket (const Socket &)
 copy constructor, don't call

Socketoperator= (const Socket &)
 assignment operator, don't call


Protected Attributes

TransportType_t trType
 private ALOKL_TODO

FlushType_t flType
 private ALOKL_TODO

int verbosity
 private ALOKL_TODO

antModuleRef endpoint
 private ALOKL_TODO

ConnectionState state
 private ALOKL_TODO

int sendBufSize
 private ALOKL_TODO

int recvBufSize
 private ALOKL_TODO

int sendSize
 private ALOKL_TODO

int recvSize
 private ALOKL_TODO

int writeSize
 private ALOKL_TODO

int readSize
 private ALOKL_TODO

bool tx
 private ALOKL_TODO

bool rx
 private ALOKL_TODO

antSharedBuffer sendBuffer
 private ALOKL_TODO

antSharedBuffer recvBuffer
 private ALOKL_TODO

byte * sendData
 private ALOKL_TODO

byte * recvData
 private ALOKL_TODO

byte * readData
 private ALOKL_TODO

byte * writeData
 private ALOKL_TODO

int server_port
 private ALOKL_TODO

int(* rcvcbckfn )(char *, int)
 private ALOKL_TODO

bool textForward
 private ALOKL_TODO

char * textForwardBuf
 private ALOKL_TODO

SocketforwardSock
 private ALOKL_TODO

bool daemon
 private ALOKL_TODO


Friends

class Wireless


Constructor & Destructor Documentation

Socket::Socket int  sockn  )  [inline, explicit]
 

constructor

Definition at line 55 of file Socket.h.

virtual Socket::~Socket  )  [inline, virtual]
 

destructor

Definition at line 64 of file Socket.h.

Socket::Socket const Socket  )  [protected]
 

copy constructor, don't call


Member Function Documentation

void Socket::flush  ) 
 

All write commands on the socket will implicity call this. You don't need to call it, unless you're implementing your own write

Reimplemented in DummySocket.

Definition at line 66 of file Socket.cc.

Referenced by Wireless::SendCont(), vprintf(), and write().

byte * Socket::getReadBuffer  ) 
 

getReadBuffer is used with blocking read's

The read(void) and getReadBuffer combo eliminates one buffer copy. You don't need to use getReadBuffer with read(byte*, int)

Blocking read is currently broken - it will be fixed in the next release

Returns:
pointer to the buffer the previous call to blocking read wrote into or NULL if no data was read

Reimplemented in DummySocket.

Definition at line 44 of file Socket.cc.

byte * Socket::getWriteBuffer int  bytesreq  ) 
 

The getWriteBuffer-write(int) combo eliminates one buffer copy. You don't need to use getWriteBuffer with write(byte*, int)

Returns:
pointer to the current position in the current write buffer for this socket or NULL on error
Parameters:
bytesreq maximum number of bytes the caller intends to set before the write method is called

Reimplemented in DummySocket.

Definition at line 11 of file Socket.cc.

Referenced by SegCamBehavior::openPacket(), RawCamBehavior::openPacket(), WorldStateSerializerBehavior::processEvent(), WMMonitorBehavior::report(), DumpFileControl::selectedFile(), and write().

void Socket::init  ) 
 

initialize socket member variables. This is different from the constructor since sockets are reused

Reimplemented in DummySocket.

Definition at line 51 of file Socket.cc.

Referenced by Wireless::connect(), and Wireless::listen().

Socket& Socket::operator= const Socket  )  [protected]
 

assignment operator, don't call

int Socket::pprintf int  vlevel,
const char *  fmt,
... 
 

Similar to printf, except it takes an extra first argument.

If vlevel is than or equal to the current verbosity level, the string will be printed else it will be ignored

Parameters:
vlevel if (vlevel<=verbosity) print, else ignore
fmt same as the standard printf's format string

Reimplemented in DummySocket.

Definition at line 92 of file Socket.cc.

int Socket::printf const char *  fmt,
... 
 

It's standard stuff. man 3 printf on most systems should give you more information

Reimplemented in DummySocket.

Definition at line 106 of file Socket.cc.

Referenced by ProfilerCheckControl::activate(), HelpControl::activate(), BatteryCheckControl::activate(), WalkCalibration::addSample(), JPEGGenerator::calcImage(), SensorObserverControl::checkLogFile(), EventLogger::checkLogFile(), ControlBase::clearMenu(), Controller::closeGUI(), ControlBase::doReadStdIn(), WalkCalibration::doSelect(), ValueEditControl< T >::doSelect(), ControlBase::doSelect(), HelloWorldBehavior::DoStart(), CrashTestBehavior::DoStart(), Controller::DoStop(), EmergencyStopMC::EmergencyStopMC(), WalkCalibration::err(), FreeMemReportControl::freeMem(), CameraBehavior::getNextName(), Controller::init(), CameraBehavior::initIndex(), WalkMC::LoadBuffer(), SegmentedColorGenerator::LoadBuffer(), RLEGenerator::LoadBuffer(), RegionGenerator::LoadBuffer(), RawCameraGenerator::LoadBuffer(), JPEGGenerator::LoadBuffer(), InterleavedYUVGenerator::LoadBuffer(), SegmentedColorGenerator::loadColorInfo(), WalkCalibration::loadData(), SegmentedColorGenerator::loadThresholdMap(), CameraBehavior::openNextFile(), ValueEditControl< T >::pause(), Controller::pop(), pprintf(), WalkCalibration::processEvent(), ValueEditControl< T >::processEvent(), SensorObserverControl::processEvent(), RegionGenerator::processEvent(), FreeMemReportControl::processEvent(), EventLogger::processEvent(), EStopControllerBehavior::processEvent(), CameraBehavior::processEvent(), BallDetectionGenerator::processEvent(), Controller::push(), LoadCalibration< ROWS, COLS >::readData(), WalkCalibration::refresh(), ValueEditControl< T >::refresh(), ControlBase::refresh(), WalkCalibration::report(), HelpControl::report(), FreeMemReportControl::report(), BatteryCheckControl::report(), EStopControllerBehavior::runCommand(), JPEGGenerator::SaveBuffer(), WalkCalibration::saveData(), LoadWalkControl::selectedFile(), DumpFileControl::selectedFile(), ExploreMachine::setup(), WalkCalibration::setupMoving(), BatteryMonitorBehavior::startWarning(), BatteryMonitorBehavior::stopWarning(), SaveWalkControl::takeInput(), ControlBase::takeInput(), Controller::takeLine(), and EmergencyStopMC::trigger().

int Socket::read byte *  buf,
int  size
 

Blocking read.

You might want to consider the read(void) and getReadBuffer combo if you call this often

Blocking read is currently broken - it will be fixed in the next release

Parameters:
buf buffer to write from
size number of bytes to write
Returns:
number of bytes actually read

Reimplemented in DummySocket.

Definition at line 157 of file Socket.cc.

int Socket::read  ) 
 

Blocking read.

Tries to read upto receive buffer size worth of data from this socket.

Blocking read is currently broken - it will be fixed in the next release

Returns:
number of bytes read or -1 on error

Reimplemented in DummySocket.

Definition at line 38 of file Socket.cc.

int Socket::setFlushType FlushType_t  fType  ) 
 

Chooses between blocking and non-blocking input, output.

This function can only be called when a socket is disconnected, since it is a bad idea to mix blocking and non-blocking input, output. The default for a socket is non-blocking

Returns:
0 on success

Reimplemented in DummySocket.

Definition at line 58 of file Socket.cc.

Referenced by MMCombo::DoInit().

void Socket::setForward Socket forsock  )  [inline]
 

causes this socket to forward output to sock if it is not connected, pass NULL to unset

Definition at line 117 of file Socket.h.

Referenced by MMCombo::DoInit().

void Socket::setTextForward  )  [inline]
 

causes this socket to forward output to stdout if it is not connected, call setForward(NULL) to unset

Reimplemented in DummySocket.

Definition at line 114 of file Socket.h.

Referenced by MMCombo::DoInit().

void Socket::setVerbosity int  verbose  )  [inline]
 

Picks a level of verbosity for filtering pprintf commands.

The higher the verbosity, the more the number of messages printed. This is useful for filtering out non-important messages with very little processor cost. Default is 0.

Parameters:
verbose the higher the value of verbose, the more the output

Reimplemented in DummySocket.

Definition at line 126 of file Socket.h.

int Socket::vprintf const char *  fmt,
va_list  al
 

It's standard stuff. man 3 printf on most systems should give you more information

Reimplemented in DummySocket.

Definition at line 116 of file Socket.cc.

Referenced by printf().

int Socket::write const byte *  buf,
int  size
 

You might want to consider the getWriteBuffer-write(int) combo if you call this often

Parameters:
buf buffer to write from
size number of bytes to write
Returns:
the number of bytes actually written or -1 on error

Reimplemented in DummySocket.

Definition at line 139 of file Socket.cc.

void Socket::write int  size  ) 
 

writes the specified number of bytes starting at the pointer returned.

in a (prior) call to getWriteBufer

Parameters:
size number of bytes to be sent from the current write buffer

Reimplemented in DummySocket.

Definition at line 26 of file Socket.cc.

Referenced by SegCamBehavior::closePacket(), RawCamBehavior::closePacket(), StringInputControl::doReadStdIn(), Controller::loadGUI(), WorldStateSerializerBehavior::processEvent(), ControlBase::refresh(), BatteryCheckControl::refresh(), WMMonitorBehavior::report(), DumpFileControl::selectedFile(), and write().


Friends And Related Function Documentation

friend class Wireless [friend]
 

Reimplemented in DummySocket.

Definition at line 48 of file Socket.h.


Member Data Documentation

bool Socket::daemon [protected]
 

private ALOKL_TODO

Definition at line 198 of file Socket.h.

Referenced by Wireless::close(), Wireless::CloseCont(), Wireless::setDaemon(), and Socket().

antModuleRef Socket::endpoint [protected]
 

private ALOKL_TODO

Definition at line 182 of file Socket.h.

Referenced by Wireless::connect(), Wireless::listen(), and Socket().

FlushType_t Socket::flType [protected]
 

private ALOKL_TODO

Definition at line 178 of file Socket.h.

Referenced by flush(), setFlushType(), and Socket().

Socket* Socket::forwardSock [protected]
 

private ALOKL_TODO

Definition at line 196 of file Socket.h.

Referenced by flush(), getWriteBuffer(), setForward(), setTextForward(), Socket(), vprintf(), and write().

int(* Socket::rcvcbckfn)(char*, int) [protected]
 

private ALOKL_TODO

Referenced by Wireless::ConnectCont(), Wireless::ListenCont(), Wireless::receive(), Wireless::ReceiveCont(), Wireless::setReceiver(), and Socket().

byte* Socket::readData [protected]
 

private ALOKL_TODO

Definition at line 190 of file Socket.h.

Referenced by Wireless::socket(), and Socket().

int Socket::readSize [protected]
 

private ALOKL_TODO

Definition at line 185 of file Socket.h.

Referenced by Socket().

antSharedBuffer Socket::recvBuffer [protected]
 

private ALOKL_TODO

Definition at line 188 of file Socket.h.

Referenced by Wireless::close(), Wireless::socket(), and Socket().

int Socket::recvBufSize [protected]
 

private ALOKL_TODO

Definition at line 185 of file Socket.h.

Referenced by Wireless::socket(), and Socket().

byte * Socket::recvData [protected]
 

private ALOKL_TODO

Definition at line 189 of file Socket.h.

Referenced by Wireless::socket(), and Socket().

int Socket::recvSize [protected]
 

private ALOKL_TODO

Definition at line 185 of file Socket.h.

Referenced by Wireless::ReceiveCont(), and Socket().

bool Socket::rx [protected]
 

private ALOKL_TODO

Definition at line 186 of file Socket.h.

Referenced by Wireless::hasData(), Wireless::receive(), and Socket().

antSharedBuffer Socket::sendBuffer [protected]
 

private ALOKL_TODO

Definition at line 188 of file Socket.h.

Referenced by Wireless::close(), Wireless::socket(), and Socket().

int Socket::sendBufSize [protected]
 

private ALOKL_TODO

Definition at line 185 of file Socket.h.

Referenced by getWriteBuffer(), Wireless::socket(), Socket(), and vprintf().

byte* Socket::sendData [protected]
 

private ALOKL_TODO

Definition at line 189 of file Socket.h.

Referenced by flush(), Wireless::socket(), and Socket().

int Socket::sendSize [protected]
 

private ALOKL_TODO

Definition at line 185 of file Socket.h.

Referenced by Wireless::blockingSend(), flush(), init(), Wireless::send(), and Socket().

int Socket::server_port [protected]
 

private ALOKL_TODO

Definition at line 191 of file Socket.h.

Referenced by Wireless::close(), Wireless::CloseCont(), Wireless::listen(), and Socket().

int Socket::sock
 

unique non-negative integer representing socket. Serves as index into socket Objects array

Definition at line 51 of file Socket.h.

Referenced by Wireless::close(), Wireless::connect(), Controller::console_callback(), StringInputControl::doReadStdIn(), ControlBase::doReadStdIn(), WMMonitorBehavior::DoStart(), WalkControllerBehavior::DoStart(), HeadPointControllerBehavior::DoStart(), EStopControllerBehavior::DoStart(), Controller::DoStart(), Aibo3DControllerBehavior::DoStart(), SegCamBehavior::DoStop(), RawCamBehavior::DoStop(), flush(), Wireless::listen(), SegCamBehavior::processEvent(), RawCamBehavior::processEvent(), WalkCalibration::refresh(), ValueEditControl< T >::refresh(), ControlBase::refresh(), BatteryCheckControl::refresh(), Wireless::setDaemon(), Wireless::setReceiver(), and Socket().

ConnectionState Socket::state [protected]
 

private ALOKL_TODO

Definition at line 183 of file Socket.h.

Referenced by Wireless::BindCont(), Wireless::blockingSend(), Wireless::close(), Wireless::CloseCont(), Wireless::connect(), Wireless::ConnectCont(), flush(), getWriteBuffer(), Wireless::isConnected(), Wireless::listen(), Wireless::ListenCont(), Wireless::receive(), Wireless::ReceiveCont(), Wireless::send(), Wireless::SendCont(), setFlushType(), Socket(), vprintf(), and write().

bool Socket::textForward [protected]
 

private ALOKL_TODO

Definition at line 194 of file Socket.h.

Referenced by getWriteBuffer(), setForward(), setTextForward(), Socket(), vprintf(), and write().

char* Socket::textForwardBuf [protected]
 

private ALOKL_TODO

Definition at line 195 of file Socket.h.

Referenced by getWriteBuffer(), Socket(), and write().

TransportType_t Socket::trType [protected]
 

private ALOKL_TODO

Definition at line 177 of file Socket.h.

Referenced by Wireless::connect(), Wireless::listen(), Wireless::socket(), and Socket().

bool Socket::tx [protected]
 

private ALOKL_TODO

Definition at line 186 of file Socket.h.

Referenced by Wireless::blockingSend(), flush(), Wireless::isReady(), Wireless::send(), Wireless::SendCont(), and Socket().

int Socket::verbosity [protected]
 

private ALOKL_TODO

Definition at line 180 of file Socket.h.

Referenced by pprintf(), setVerbosity(), and Socket().

byte * Socket::writeData [protected]
 

private ALOKL_TODO

Definition at line 190 of file Socket.h.

Referenced by flush(), getWriteBuffer(), Wireless::socket(), Socket(), and vprintf().

int Socket::writeSize [protected]
 

private ALOKL_TODO

Definition at line 185 of file Socket.h.

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


The documentation for this class was generated from the following files:
Tekkotsu v2.0
Generated Wed Jan 21 03:23:27 2004 by Doxygen 1.3.4