Aria
2.8.0
|
For connecting to a device through a TCP network socket. More...
#include <ArTcpConnection.h>
Inherits ArDeviceConnection.
Public Types | |
enum | Open { OPEN_NET_FAIL = 1, OPEN_BAD_HOST, OPEN_NO_ROUTE, OPEN_CON_REFUSED } |
Public Types inherited from ArDeviceConnection | |
enum | Status { STATUS_NEVER_OPENED = 1, STATUS_OPEN, STATUS_OPEN_FAILED, STATUS_CLOSED_NORMALLY, STATUS_CLOSED_ERROR } |
Public Member Functions | |
ArTcpConnection () | |
Constructor. | |
virtual bool | close (void) |
std::string | getHost (void) |
Gets the name of the host connected to. More... | |
virtual const char * | getOpenMessage (int messageNumber) |
int | getPort (void) |
Gets the number of the port connected to. More... | |
ArSocket * | getSocket (void) |
Gets the socket this tcp connection is using. | |
virtual int | getStatus (void) |
virtual ArTime | getTimeRead (int index) |
int | internalOpen (void) |
Internal function used by open and openSimple. | |
virtual bool | isTimeStamping (void) |
int | open (const char *host=NULL, int port=8101) |
Opens a connection to the given host and port. More... | |
virtual bool | openSimple (void) |
virtual int | read (const char *data, unsigned int size, unsigned int msWait=0) |
void | setPort (const char *host=NULL, int port=8101) |
void | setSocket (ArSocket *socket) |
Sets the tcp connection to use this socket instead of its own. More... | |
void | setStatus (int status) |
Sets the status of the device, ONLY use this if you're playing with setSocket and know what you're doing. | |
virtual int | write (const char *data, unsigned int size) |
virtual | ~ArTcpConnection () |
Destructor also closes connection. | |
Public Member Functions inherited from ArDeviceConnection | |
ArDeviceConnection () | |
constructor More... | |
void | debugBytesRead (int bytesRead) |
Notifies the device connection that some bytes were read (should call with 0 if it read but got no bytes) | |
void | debugEndPacket (bool goodPacket, int type=0) |
Notifies the device connection that the end of a packet was read, which will cause log messages if set to do so. | |
void | debugStartPacket (void) |
Notifies the device connection that the start of a packet is trying to be read. | |
const char * | getDeviceName (void) const |
Gets the device type (what this is connecting to) | |
const char * | getPortName (void) const |
Gets the port name. | |
const char * | getPortType (void) const |
Gets the port type. | |
const char * | getStatusMessage (int messageNumber) const |
Gets the description string associated with the status. More... | |
void | setDeviceName (const char *deviceName) |
Sets the device type (what this is connecting to) | |
virtual int | writePacket (ArBasePacket *packet) |
Writes data to connection. More... | |
virtual | ~ArDeviceConnection () |
destructor also forces a close on the connection | |
Protected Member Functions | |
void | buildStrMap (void) |
Protected Member Functions inherited from ArDeviceConnection | |
void | buildStrMap (void) |
void | setPortName (const char *portName) |
Sets the port name. | |
void | setPortType (const char *portType) |
Sets the port type. | |
Protected Attributes | |
std::string | myHostName |
bool | myOwnSocket |
int | myPortNum |
ArSocket * | mySocket |
int | myStatus |
ArStrMap | myStrMap |
Protected Attributes inherited from ArDeviceConnection | |
int | myDCDebugBytesRead |
ArTime | myDCDebugFirstByteTime |
ArTime | myDCDebugLastByteTime |
long long | myDCDebugNumBadPackets |
long long | myDCDebugNumGoodPackets |
bool | myDCDebugPacketStarted |
ArTime | myDCDebugStartTime |
int | myDCDebugTimesRead |
std::string | myDCDeviceName |
std::string | myDCPortName |
std::string | myDCPortType |
Additional Inherited Members | |
Static Public Member Functions inherited from ArDeviceConnection | |
static bool | debugShouldLog (bool shouldLog) |
Makes all device connections so that they'll dump data. | |
Static Protected Attributes inherited from ArDeviceConnection | |
static ArTime | ourDCDebugFirstTime |
static bool | ourDCDebugShouldLog = false |
static ArStrMap | ourStrMap |
static bool | ourStrMapInited = false |
For connecting to a device through a TCP network socket.
std::string ArTcpConnection::getHost | ( | void | ) |
int ArTcpConnection::getPort | ( | void | ) |
Gets the number of the port connected to.
int ArTcpConnection::open | ( | const char * | host = NULL , |
int | port = 8101 |
||
) |
Opens a connection to the given host and port.
host | the hostname or IP address to connect to, if NULL (default) then localhost |
port | the port to connect to. (the default port, 8101, is the TCP port number used by the wireless bridge device and by the simulator for robot connection) |
void ArTcpConnection::setSocket | ( | ArSocket * | socket | ) |
Sets the tcp connection to use this socket instead of its own.
This will make the connection use this socket, its useful for doing funkier things with sockets but still being able to use a device connection.
socket | the socket to use |