Urbi SDK Remote for C++  2.7.5
urbi::UClient Class Reference

Linux implementation of UAbstractClient. More...

#include <uclient.hh>

Inheritance diagram for urbi::UClient:
Collaboration diagram for urbi::UClient:

List of all members.

Classes

struct  options
 Construction options. More...

Public Member Functions

 UClient (const std::string &host=default_host(), unsigned port=URBI_PORT, size_t buflen=URBI_BUFLEN, const UClient::options &opt=options(false))
virtual ~UClient ()
virtual void waitForKernelVersion () const
 Block until kernel version is available or an error occurrs.
error_type start ()
 Bounce to listen or connect, depending whether server mode.
int closeUClient ()
virtual void printf (const char *format,...)
 Notify of an error.
virtual unsigned int getCurrentTime () const
 Get time in milliseconds since an unspecified but constant reference time.
virtual void setKeepAliveCheck (unsigned pingInterval, unsigned pongTimeout)
 Activate KeepAlive functionality.
void setSynchronousSend (bool enable)
 Use synchronous or asynchronous send.

Protected Types

typedef boost::shared_ptr
< UClient * > 
link_type

Protected Member Functions

virtual error_type onClose ()
 Executed when closing connection.
virtual int effectiveSend (const void *buffer, size_t size)
 Queue data for sending, returns zero on success, nonzero on failure.
libport::Socket * mySocketFactory ()
virtual void onConnect ()
virtual void onError (boost::system::error_code erc)
virtual size_t onRead (const void *, size_t length)
void pongTimeout (link_type l)
 Send timeout error.
void sendPing (link_type l)

Protected Attributes

libport::utime_t ping_interval_
 Delay (in microseconds) without activity to check if the connection is yet available.
libport::utime_t pong_timeout_
 Delay (in microseconds) of timeout to wait 'PONG'.
link_type link_
libport::utime_t ping_sent_
libport::AsyncCallHandler pong_timeout_handler_
libport::AsyncCallHandler send_ping_handler_
libport::Semaphore ping_sem_

Private Member Functions

error_type connect_ ()
 Wrapper around Socket::connect.
error_type listen_ ()
 Wrapper around Socket::listen.
void resetAsyncCalls_ ()
 Reset all asynchronous calls.

Private Attributes

bool asynchronous_
 Make an asynchronous connect.
bool synchronous_send_
 Use synchronous/asynchronous send.

Detailed Description

Linux implementation of UAbstractClient.

This implementation uses a shared thread between all the instances to handle Socket operations, and call the registered callbacks in that thread.

Definition at line 29 of file uclient.hh.


Member Typedef Documentation

typedef boost::shared_ptr<UClient*> urbi::UClient::link_type [protected]

Definition at line 138 of file uclient.hh.


Constructor & Destructor Documentation

urbi::UClient::UClient ( const std::string &  host = default_host(),
unsigned  port = URBI_PORT,
size_t  buflen = URBI_BUFLEN,
const UClient::options opt = options(false) 
)

Create a new client and tries to connect to the server. Will block until the connection is established or timeouts.

Parameters:
hostIP address or name of the robot to connect to.
portTCP port to connect to.
buflensize of send and receive buffers.
optoptions: whether server, whether autostart.

Definition at line 53 of file uclient.cc.

References start().

Referenced by urbi::connect().

urbi::UClient::~UClient ( ) [virtual]

Definition at line 105 of file uclient.cc.

References closeUClient(), and link_.


Member Function Documentation

UClient::error_type urbi::UClient::closeUClient ( )

Definition at line 120 of file uclient.cc.

References onClose().

Referenced by ~UClient().

UClient::error_type urbi::UClient::connect_ ( ) [private]

Wrapper around Socket::connect.

Client mode.

Definition at line 76 of file uclient.cc.

References asynchronous_, urbi::connect(), urbi::UAbstractClient::host_, and urbi::UAbstractClient::port_.

Referenced by start().

UClient::error_type urbi::UClient::effectiveSend ( const void *  buffer,
size_t  size 
) [protected, virtual]

Queue data for sending, returns zero on success, nonzero on failure.

Implements urbi::UAbstractClient.

Definition at line 128 of file uclient.cc.

References urbi::UAbstractClient::rc, and synchronous_send_.

unsigned int urbi::UClient::getCurrentTime ( ) const [virtual]

Get time in milliseconds since an unspecified but constant reference time.

Implements urbi::UAbstractClient.

Definition at line 250 of file uclient.cc.

UClient::error_type urbi::UClient::listen_ ( ) [private]

Wrapper around Socket::listen.

Server mode.

Definition at line 91 of file uclient.cc.

References urbi::UAbstractClient::host_, mySocketFactory(), and urbi::UAbstractClient::port_.

Referenced by start().

libport::Socket * urbi::UClient::mySocketFactory ( ) [protected]

Definition at line 140 of file uclient.cc.

Referenced by listen_().

UClient::error_type urbi::UClient::onClose ( ) [protected, virtual]

Executed when closing connection.

Reimplemented from urbi::UAbstractClient.

Reimplemented in urbi::USyncClient.

Definition at line 112 of file uclient.cc.

References urbi::UAbstractClient::closed_.

Referenced by closeUClient().

void urbi::UClient::onError ( boost::system::error_code  erc) [protected, virtual]
void urbi::UClient::pongTimeout ( link_type  l) [protected]

Send timeout error.

Definition at line 215 of file uclient.cc.

References urbi::UAbstractClient::clientError(), urbi::connectionTimeoutTag, and urbi::UAbstractClient::notifyCallbacks().

Referenced by sendPing().

void urbi::UClient::printf ( const char *  format,
  ... 
) [virtual]

Notify of an error.

Implements urbi::UAbstractClient.

Definition at line 242 of file uclient.cc.

void urbi::UClient::resetAsyncCalls_ ( ) [private]

Reset all asynchronous calls.

Definition at line 276 of file uclient.cc.

References pong_timeout_handler_, and send_ping_handler_.

Referenced by onError(), and setKeepAliveCheck().

void urbi::UClient::sendPing ( link_type  l) [protected]
void urbi::UClient::setKeepAliveCheck ( unsigned  pingInterval,
unsigned  pongTimeout 
) [virtual]

Activate KeepAlive functionality.

Parameters:
pingIntervalis in milliseconds.
pongTimeoutis in milliseconds.

Implements urbi::UAbstractClient.

Definition at line 263 of file uclient.cc.

References link_, ping_interval_, pong_timeout_, resetAsyncCalls_(), and sendPing().

void urbi::UClient::setSynchronousSend ( bool  enable)

Use synchronous or asynchronous send.

Definition at line 299 of file uclient.cc.

References synchronous_send_.

UClient::error_type urbi::UClient::start ( )

Bounce to listen or connect, depending whether server mode.

Definition at line 70 of file uclient.cc.

References connect_(), listen_(), urbi::UAbstractClient::rc, and urbi::UAbstractClient::server_.

Referenced by UClient(), and urbi::USyncClient::USyncClient().

void urbi::UClient::waitForKernelVersion ( ) const [virtual]

Block until kernel version is available or an error occurrs.

Message processing must not depend on this thread.

Implements urbi::UAbstractClient.

Definition at line 291 of file uclient.cc.

References urbi::UAbstractClient::error(), and urbi::UAbstractClient::kernelMajor_.


Member Data Documentation

Make an asynchronous connect.

Definition at line 163 of file uclient.hh.

Referenced by connect_().

Definition at line 139 of file uclient.hh.

Referenced by onConnect(), onRead(), sendPing(), setKeepAliveCheck(), and ~UClient().

libport::utime_t urbi::UClient::ping_interval_ [protected]

Delay (in microseconds) without activity to check if the connection is yet available.

Definition at line 133 of file uclient.hh.

Referenced by onConnect(), onRead(), and setKeepAliveCheck().

libport::Semaphore urbi::UClient::ping_sem_ [protected]

Definition at line 151 of file uclient.hh.

Referenced by onRead(), and sendPing().

libport::utime_t urbi::UClient::ping_sent_ [protected]

Definition at line 146 of file uclient.hh.

Referenced by onRead(), and sendPing().

libport::utime_t urbi::UClient::pong_timeout_ [protected]

Delay (in microseconds) of timeout to wait 'PONG'.

Definition at line 136 of file uclient.hh.

Referenced by sendPing(), and setKeepAliveCheck().

libport::AsyncCallHandler urbi::UClient::pong_timeout_handler_ [protected]

Definition at line 148 of file uclient.hh.

Referenced by onRead(), resetAsyncCalls_(), and sendPing().

libport::AsyncCallHandler urbi::UClient::send_ping_handler_ [protected]

Definition at line 149 of file uclient.hh.

Referenced by onRead(), and resetAsyncCalls_().

Use synchronous/asynchronous send.

Definition at line 165 of file uclient.hh.

Referenced by effectiveSend(), and setSynchronousSend().


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