Socket Class Reference#include <Socket.h>
Inheritance diagram for Socket:
[legend]List of all members.
Detailed Description
Tekkotsu wireless Socket 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 59 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
|
Socket & | operator= (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
|
Socket * | forwardSock |
| private ALOKL_TODO
|
bool | daemon |
| private ALOKL_TODO
|
Friends |
class | Wireless |
Constructor & Destructor Documentation
Socket::Socket |
( |
int |
sockn |
) |
[inline, explicit] |
|
|
constructor
Definition at line 67 of file Socket.h. |
virtual Socket::~Socket |
( |
|
) |
[inline, virtual] |
|
|
destructor
Definition at line 76 of file Socket.h. |
Socket::Socket |
( |
const Socket & |
|
) |
[protected] |
|
|
copy constructor, don't call
|
Member Function Documentation
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 46 of file Socket.cc. |
byte * Socket::getWriteBuffer |
( |
int |
bytesreq |
) |
|
|
|
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 98 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 112 of file Socket.cc.
Referenced by Transition::activate(), ProfilerCheckControl::activate(), HelpControl::activate(), BehaviorReportControl::activate(), BatteryCheckControl::activate(), WalkCalibration::addSample(), JPEGGenerator::calcImage(), SensorObserverControl::checkLogFile(), EventLogger::checkLogFile(), ControlBase::clearMenu(), Controller::closeGUI(), ControlBase::doReadStdIn(), WalkCalibration::doSelect(), ValueEditControl< T >::doSelect(), ControlBase::doSelect(), StateNode::DoStart(), SegCamBehavior::DoStart(), RawCamBehavior::DoStart(), HelloWorldBehavior::DoStart(), FreezeTestBehavior::DoStart(), CrashTestBehavior::DoStart(), Controller::DoStop(), EmergencyStopMC::EmergencyStopMC(), WalkCalibration::err(), FreeMemReportControl::freeMem(), Kinematics::getInterestPoint(), CameraBehavior::getNextName(), Kinematics::init(), Controller::init(), CameraBehavior::initIndex(), WalkMC::LoadBuffer(), SegmentedColorGenerator::LoadBuffer(), RLEGenerator::LoadBuffer(), RegionGenerator::LoadBuffer(), RawCameraGenerator::LoadBuffer(), JPEGGenerator::LoadBuffer(), InterleavedYUVGenerator::LoadBuffer(), CDTGenerator::LoadBuffer(), SegmentedColorGenerator::loadColorInfo(), WalkCalibration::loadData(), SegmentedColorGenerator::loadThresholdMap(), Kinematics::lookup(), MotionSequenceMC< MAXMOVE >::newKeyFrame(), CameraBehavior::openNextFile(), ValueEditControl< T >::pause(), Controller::pop(), pprintf(), WalkCalibration::processEvent(), ValueEditControl< T >::processEvent(), StareAtPawBehavior2::processEvent(), StareAtPawBehavior::processEvent(), SensorObserverControl::processEvent(), RegionGenerator::processEvent(), PostureEditor::processEvent(), KinematicSampleBehavior2::processEvent(), KinematicSampleBehavior::processEvent(), FreeMemReportControl::processEvent(), EventLogger::processEvent(), EStopControllerBehavior::processEvent(), CameraBehavior::processEvent(), BallDetectionGenerator::processEvent(), Controller::push(), LoadCalibration::readData(), LoadCalibration::readMaxs(), WaypointWalkControl::refresh(), WalkCalibration::refresh(), ValueEditControl< T >::refresh(), ControlBase::refresh(), WMMonitorBehavior::registerData(), WMMonitorBehavior::report(), WalkCalibration::report(), HelpControl::report(), FreeMemReportControl::report(), BatteryCheckControl::report(), EStopControllerBehavior::runCommand(), JPEGGenerator::SaveBuffer(), WalkCalibration::saveData(), RawCameraGenerator::SaveFileStream(), 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 163 of file Socket.cc. |
|
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 40 of file Socket.cc.
Referenced by DumpFileControl::selectedFile(). |
|
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 60 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 129 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 126 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 138 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 122 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 145 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 28 of file Socket.cc.
Referenced by SegCamBehavior::closePacket(), RawCamBehavior::closePacket(), StringInputControl::doReadStdIn(), Controller::loadGUI(), WorldStateSerializerBehavior::processEvent(), MicrophoneServer::processEvent(), ControlBase::refresh(), BatteryCheckControl::refresh(), WMMonitorBehavior::report(), DumpFileControl::selectedFile(), and write(). |
Friends And Related Function Documentation
Member Data Documentation
|
private ALOKL_TODO
Definition at line 202 of file Socket.h. |
|
unique non-negative integer representing socket. Serves as index into socket Objects array
Definition at line 63 of file Socket.h.
Referenced by Wireless::close(), Wireless::connect(), Controller::console_callback(), StringInputControl::doReadStdIn(), ControlBase::doReadStdIn(), WMMonitorBehavior::DoStart(), WalkControllerBehavior::DoStart(), SpeakerServer::DoStart(), MicrophoneServer::DoStart(), HeadPointControllerBehavior::DoStart(), EStopControllerBehavior::DoStart(), Controller::DoStart(), Aibo3DControllerBehavior::DoStart(), SegCamBehavior::DoStop(), RawCamBehavior::DoStop(), flush(), Wireless::listen(), SegCamBehavior::processEvent(), RawCamBehavior::processEvent(), MicrophoneServer::processEvent(), WalkCalibration::refresh(), ValueEditControl< T >::refresh(), ControlBase::refresh(), BatteryCheckControl::refresh(), Wireless::setDaemon(), and Wireless::setReceiver(). |
|
private ALOKL_TODO
Definition at line 200 of file Socket.h.
Referenced by Wireless::BindCont(), Wireless::blockingSend(), Wireless::close(), Wireless::CloseCont(), Wireless::connect(), Wireless::ConnectCont(), flush(), getWriteBuffer(), Wireless::listen(), Wireless::ListenCont(), Wireless::receive(), Wireless::ReceiveCont(), Wireless::send(), Wireless::SendCont(), setFlushType(), vprintf(), and write(). |
|
private ALOKL_TODO
Definition at line 211 of file Socket.h. |
|
private ALOKL_TODO
Definition at line 189 of file Socket.h.
Referenced by Wireless::blockingSend(), Wireless::close(), Wireless::connect(), Wireless::ConnectCont(), Wireless::listen(), Wireless::ListenCont(), Wireless::receive(), Wireless::ReceiveCont(), Wireless::send(), Wireless::SendCont(), and Wireless::socket(). |
|
private ALOKL_TODO
Definition at line 192 of file Socket.h. |
The documentation for this class was generated from the following files:
|