Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArTcpConnection Class Reference

For connectiong to a device through a socket. More...

#include <ArTcpConnection.h>

Inheritance diagram for ArTcpConnection:

ArDeviceConnection List of all members.

Public Types

enum  Open { OPEN_NET_FAIL = 1, OPEN_BAD_HOST, OPEN_NO_ROUTE, OPEN_CON_REFUSED }

Public Member Functions

 ArTcpConnection ()
 Constructor.
virtual bool close (void)
 Closes the connection.
std::string getHost (void)
 Gets the name of the host connected to.
virtual const char * getOpenMessage (int messageNumber)
 Gets the string of the message associated with opening the device.
int getPort (void)
 Gets the number of the port connected to.
ArSocketgetSocket (void)
 Gets the socket this tcp connection is using.
virtual int getStatus (void)
 Gets the status of the connection, which is one of the enum status.
virtual ArTime getTimeRead (int index)
 Gets the time data was read in.
int internalOpen (void)
 Internal function used by open and openSimple.
virtual bool isTimeStamping (void)
 sees if timestamping is really going on or not
int open (const char *host=NULL, int port=8101)
 Opens a connection to the given host and port.
virtual bool openSimple (void)
 Opens the connection again, using the values from setLocation or.
virtual int read (const char *data, unsigned int size, unsigned int msWait=0)
 Reads data from connection.
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.
void setStatus (int status)
virtual int write (const char *data, unsigned int size)
 Writes data to connection.
virtual ~ArTcpConnection ()
 Destructor also closes connection.

Protected Member Functions

void buildStrMap (void)

Protected Attributes

std::string myHostName
bool myOwnSocket
int myPortNum
ArSocketmySocket
int myStatus
ArStrMap myStrMap

Detailed Description

For connectiong to a device through a socket.

Definition at line 37 of file ArTcpConnection.h.


Member Enumeration Documentation

enum ArTcpConnection::Open
 

Enumeration values:
OPEN_NET_FAIL  Some critical part of the network isn't working.
OPEN_BAD_HOST  Could not find the host.
OPEN_NO_ROUTE  Know where the host is, but can't get to it.
OPEN_CON_REFUSED  Got to the host but it didn't allow a connection.

Definition at line 75 of file ArTcpConnection.h.


Member Function Documentation

bool ArTcpConnection::close void   )  [virtual]
 

Closes the connection.

Returns:
whether the close succeeded or not

Reimplemented from ArDeviceConnection.

Definition at line 146 of file ArTcpConnection.cpp.

References ArSocket::close().

Referenced by ArACTS_1_2::closePort(), and write().

std::string ArTcpConnection::getHost void   ) 
 

Gets the name of the host connected to.

Returns:
the name of the host connected to
See also:
getPort

Definition at line 215 of file ArTcpConnection.cpp.

const char * ArTcpConnection::getOpenMessage int  messageNumber  )  [virtual]
 

Gets the string of the message associated with opening the device.

Each class inherited from this one has an open method which returns 0 for success or an integer which can be passed into this function to obtain a string describing the reason for failure

Parameters:
messageNumber the number returned from the open
Returns:
the error description associated with the messageNumber

Implements ArDeviceConnection.

Definition at line 141 of file ArTcpConnection.cpp.

Referenced by ArACTS_1_2::openPort().

int ArTcpConnection::getPort void   ) 
 

Gets the number of the port connected to.

Returns:
the number of the port connected to
See also:
getHost

Definition at line 224 of file ArTcpConnection.cpp.

int ArTcpConnection::getStatus void   )  [virtual]
 

Gets the status of the connection, which is one of the enum status.

Gets the status of the connection, which is one of the enum status. If you want to get a string to go along with the number, use getStatusMessage

Returns:
the status of the connection
See also:
getStatusMessage

Implements ArDeviceConnection.

Definition at line 229 of file ArTcpConnection.cpp.

Referenced by ArACTS_1_2::isConnected(), read(), ArACTS_1_2::receiveBlobInfo(), ArACTS_1_2::requestPacket(), ArACTS_1_2::requestQuit(), and write().

ArTime ArTcpConnection::getTimeRead int  index  )  [virtual]
 

Gets the time data was read in.

Parameters:
index looks like this is the index back in the number of bytes last read in
Returns:
the time the last read data was read in

Implements ArDeviceConnection.

Definition at line 239 of file ArTcpConnection.cpp.

References ArTime::setToNow().

bool ArTcpConnection::isTimeStamping void   )  [virtual]
 

sees if timestamping is really going on or not

Returns:
true if real timestamping is happening, false otherwise

Implements ArDeviceConnection.

Definition at line 234 of file ArTcpConnection.cpp.

int ArTcpConnection::open const char *  host = NULL,
int  port = 8101
 

Opens a connection to the given host and port.

Parameters:
host the host to connect to, if NULL (default) then localhost
port the port to connect to
Returns:
0 for success, otherwise one of the open enums
See also:
getOpenMessage

Definition at line 97 of file ArTcpConnection.cpp.

References internalOpen().

Referenced by ArACTS_1_2::openPort().

int ArTcpConnection::read const char *  data,
unsigned int  size,
unsigned int  msWait = 0
[virtual]
 

Reads data from connection.

Reads data from connection

Parameters:
data pointer to a character array to read the data into
size maximum number of bytes to read
msWait read blocks for this many milliseconds (not at all for == 0)
Returns:
number of bytes read, or -1 for failure
See also:
write, writePacket

Implements ArDeviceConnection.

Definition at line 152 of file ArTcpConnection.cpp.

References ArTime::addMSec(), getStatus(), ArLog::log(), ArTime::mSecTo(), ArSocket::read(), and ArTime::setToNow().

Referenced by ArACTS_1_2::receiveBlobInfo().

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.

Parameters:
sock the socket to use

Definition at line 53 of file ArTcpConnection.cpp.

void ArTcpConnection::setStatus int  status  ) 
 

Sets the status of the device, ONLY use this if you're playing with setSocket and know what you're doing

Definition at line 68 of file ArTcpConnection.cpp.

int ArTcpConnection::write const char *  data,
unsigned int  size
[virtual]
 

Writes data to connection.

Writes data to connection

Parameters:
data pointer to a character array to write the data from
size number of bytes to write
Returns:
number of bytes read, or -1 for failure
See also:
read, writePacket

Implements ArDeviceConnection.

Definition at line 192 of file ArTcpConnection.cpp.

References close(), getStatus(), ArLog::log(), and ArSocket::write().

Referenced by ArACTS_1_2::requestPacket(), and ArACTS_1_2::requestQuit().


The documentation for this class was generated from the following files:
Generated on Wed Oct 19 12:56:55 2005 for Aria by  doxygen 1.4.0