|
Urbi SDK Remote for C++
2.7.3
|
Linux implementation of UAbstractClient. More...
#include <uclient.hh>


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. | |
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.
typedef boost::shared_ptr<UClient*> urbi::UClient::link_type [protected] |
Definition at line 138 of file uclient.hh.
| 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.
| host | IP address or name of the robot to connect to. |
| port | TCP port to connect to. |
| buflen | size of send and receive buffers. |
| opt | options: 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_.
| UClient::error_type urbi::UClient::closeUClient | ( | ) |
| 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::onConnect | ( | ) | [protected, virtual] |
Reimplemented in urbi::USyncClient.
Definition at line 146 of file uclient.cc.
References urbi::UAbstractClient::host_, urbi::UAbstractClient::init_, urbi::internalPongTag, link_, urbi::UAbstractClient::onConnection(), ping_interval_, urbi::UAbstractClient::port_, urbi::UAbstractClient::send(), sendPing(), and SYNCLINE_WRAP.
| void urbi::UClient::onError | ( | boost::system::error_code | erc | ) | [protected, virtual] |
Definition at line 175 of file uclient.cc.
References urbi::UAbstractClient::clientError(), urbi::UAbstractClient::CLIENTERROR_TAG, urbi::UAbstractClient::notifyCallbacks(), urbi::UAbstractClient::rc, and resetAsyncCalls_().
| size_t urbi::UClient::onRead | ( | const void * | data, |
| size_t | length | ||
| ) | [protected, virtual] |
Definition at line 186 of file uclient.cc.
References link_, ping_interval_, ping_sem_, ping_sent_, pong_timeout_handler_, urbi::UAbstractClient::processRecvBuffer(), urbi::UAbstractClient::recvBuffer, urbi::UAbstractClient::recvBufferPosition, urbi::UAbstractClient::recvBufSize, send_ping_handler_, and sendPing().
| 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] |
| 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] |
Definition at line 228 of file uclient.cc.
References urbi::internalPongTag, link_, ping_sem_, ping_sent_, pong_timeout_, pong_timeout_handler_, pongTimeout(), and urbi::UAbstractClient::send().
Referenced by onConnect(), onRead(), and setKeepAliveCheck().
| void urbi::UClient::setKeepAliveCheck | ( | unsigned | pingInterval, |
| unsigned | pongTimeout | ||
| ) | [virtual] |
Activate KeepAlive functionality.
| pingInterval | is in milliseconds. |
| pongTimeout | is 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_.
bool urbi::UClient::asynchronous_ [private] |
link_type urbi::UClient::link_ [protected] |
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_().
bool urbi::UClient::synchronous_send_ [private] |
Use synchronous/asynchronous send.
Definition at line 165 of file uclient.hh.
Referenced by effectiveSend(), and setSynchronousSend().