Public Member Functions | Private Types | Private Member Functions | Private Attributes
apps::TCP Class Reference

#include <TCP.h>

List of all members.

Public Member Functions

int connectOnce ()
int connectOnce ()
int read (void *data, unsigned int size)
 reads data with given size from socket
int read (void *data, unsigned int size)
 reads data with given size from socket
int read (void *data, unsigned int size, unsigned int delay_us)
 return after given delay with -1 else 0 and blocks endless (wait for new connection) whenn connection is broken
int read (void *data, unsigned int size, unsigned int delay_us)
 return after given delay with -1 else 0 and blocks endless (wait for new connection) whenn connection is broken
int readAll (void *data, unsigned int size)
 reads data with given size from socket
int readAll (void *data, unsigned int size)
 reads data with given size from socket
 TCP (unsigned int port)
 TCP (unsigned int port)
 TCP (std::string ip, unsigned int port)
 TCP (std::string ip, unsigned int port)
int write (void *data, unsigned int size)
int write (void *data, unsigned int size)
virtual ~TCP ()
virtual ~TCP ()

Private Types

enum  _mode { server, client, server, client }
enum  _mode { server, client, server, client }

Private Member Functions

void read_callback (bool &data_available, boost::asio::deadline_timer &timeout, const boost::system::error_code &error, std::size_t bytes_transferred)
 callback function for reading asynchron serial data with timeout
void read_callback (bool &data_available, boost::asio::deadline_timer &timeout, const boost::system::error_code &error, std::size_t bytes_transferred)
void wait_callback (boost::asio::ip::tcp::socket &ser_port, const boost::system::error_code &error)
void wait_callback (boost::asio::ip::tcp::socket &ser_port, const boost::system::error_code &error)

Private Attributes

_mode _choosenMode
unsigned int _delay
boost::asio::io_service _ioService
std::string _ip
unsigned int _port
bool _requestNewConnection
tcp::acceptor * _server
boost::asio::ip::tcp::socket * _socket
boost::asio::ip::tcp::endpoint * _targetServer
boost::asio::deadline_timer * _timer

Detailed Description

Definition at line 29 of file firmware/src/VrMagicHandler_camhost/TCP/TCP.h.


Member Enumeration Documentation

enum apps::TCP::_mode [private]
Enumerator:
server 
client 
server 
client 

Definition at line 33 of file firmware/src/VrMagicHandler_camhost/TCP/TCP.h.

enum apps::TCP::_mode [private]
Enumerator:
server 
client 
server 
client 

Definition at line 33 of file src/TCP/TCP.h.


Constructor & Destructor Documentation

apps::TCP::TCP ( unsigned int  port)
apps::TCP::TCP ( std::string  ip,
unsigned int  port 
)
apps::TCP::~TCP ( ) [virtual]
apps::TCP::TCP ( unsigned int  port)
apps::TCP::TCP ( std::string  ip,
unsigned int  port 
)
virtual apps::TCP::~TCP ( ) [virtual]

Member Function Documentation

int apps::TCP::read ( void *  data,
unsigned int  size 
)

reads data with given size from socket

Note:
It is possible that this function does not read all given data
Parameters:
[in,out]arg-> description todo
Returns:
number of read bytes and -1 on error

Definition at line 58 of file firmware/src/VrMagicHandler_camhost/TCP/TCP.cpp.

int apps::TCP::read ( void *  data,
unsigned int  size 
)

reads data with given size from socket

Note:
It is possible that this function does not read all given data
Parameters:
[in,out]arg-> description todo
Returns:
number of read bytes and -1 on error
int apps::TCP::read ( void *  data,
unsigned int  size,
unsigned int  delay_us 
)

return after given delay with -1 else 0 and blocks endless (wait for new connection) whenn connection is broken

Parameters:
[in,out]arg-> description
Returns:
0 on succes and -1 on timeout and broken connection

Definition at line 96 of file firmware/src/VrMagicHandler_camhost/TCP/TCP.cpp.

int apps::TCP::read ( void *  data,
unsigned int  size,
unsigned int  delay_us 
)

return after given delay with -1 else 0 and blocks endless (wait for new connection) whenn connection is broken

Parameters:
[in,out]arg-> description
Returns:
0 on succes and -1 on timeout and broken connection
apps::TCP::read_callback ( bool &  data_available,
boost::asio::deadline_timer &  timeout,
const boost::system::error_code &  error,
std::size_t  bytes_transferred 
) [private]

callback function for reading asynchron serial data with timeout

Parameters:
[in,out]
Returns:
void

Definition at line 184 of file firmware/src/VrMagicHandler_camhost/TCP/TCP.cpp.

void apps::TCP::read_callback ( bool &  data_available,
boost::asio::deadline_timer &  timeout,
const boost::system::error_code &  error,
std::size_t  bytes_transferred 
) [private]
int apps::TCP::readAll ( void *  data,
unsigned int  size 
)

reads data with given size from socket

Note:
this function will block until all data is read. It is forced to read all given data
Parameters:
[in,out]arg-> description
Returns:
0 on succes and -1 on error(brocken connection)

Definition at line 73 of file firmware/src/VrMagicHandler_camhost/TCP/TCP.cpp.

int apps::TCP::readAll ( void *  data,
unsigned int  size 
)

reads data with given size from socket

Note:
this function will block until all data is read. It is forced to read all given data
Parameters:
[in,out]arg-> description
Returns:
0 on succes and -1 on error(brocken connection)
void apps::TCP::wait_callback ( boost::asio::ip::tcp::socket &  ser_port,
const boost::system::error_code &  error 
) [private]
void apps::TCP::wait_callback ( boost::asio::ip::tcp::socket &  ser_port,
const boost::system::error_code &  error 
) [private]
int apps::TCP::write ( void *  data,
unsigned int  size 
)
int apps::TCP::write ( void *  data,
unsigned int  size 
)

Member Data Documentation

unsigned int apps::TCP::_delay [private]
boost::asio::io_service apps::TCP::_ioService [private]
std::string apps::TCP::_ip [private]
unsigned int apps::TCP::_port [private]
tcp::acceptor * apps::TCP::_server [private]
boost::asio::ip::tcp::socket * apps::TCP::_socket [private]
boost::asio::ip::tcp::endpoint * apps::TCP::_targetServer [private]
boost::asio::deadline_timer * apps::TCP::_timer [private]

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


vrmagic_ros_bridge_server
Author(s): Michael Schmidpeter
autogenerated on Thu Aug 27 2015 15:40:40