Single TCP/IP connection manager.
More...
#include <transport/transport.hh>
|
typedef boost::function< void(const
ConnectionPtr &)> | AcceptCallback |
| | The signature of a connection accept callback.
|
| |
typedef boost::function< void(const
std::string &_data)> | ReadCallback |
| | The signature of a connection read callback.
|
| |
|
| | Connection () |
| | Constructor.
|
| |
| virtual | ~Connection () |
| | Destructor.
|
| |
| template<typename Handler > |
| void | AsyncRead (Handler _handler) |
| | Peform an asyncronous read param[in] _handler Callback to invoke on received data.
|
| |
| void | Cancel () |
| | Cancel all async operations on an open socket.
|
| |
| bool | Connect (const std::string &_host, unsigned int _port) |
| | Connect to a remote host.
|
| |
| event::ConnectionPtr | ConnectToShutdown (boost::function< void()> _subscriber) |
| | Register a function to be called when the connection is shut down.
|
| |
| void | DisconnectShutdown (event::ConnectionPtr _subscriber) |
| | Unregister a function to be called when the connection is shut down.
|
| |
| void | EnqueueMsg (const std::string &_buffer, bool _force=false) |
| | Write data to the socket.
|
| |
| unsigned int | GetId () const |
| | Get the ID of the connection.
|
| |
| std::string | GetLocalAddress () const |
| | Get the local address of this connection.
|
| |
| std::string | GetLocalHostname () const |
| | Get the local hostname.
|
| |
| unsigned int | GetLocalPort () const |
| | Get the port of this connection.
|
| |
| std::string | GetLocalURI () const |
| | Get the local URI.
|
| |
| std::string | GetRemoteAddress () const |
| | Get the remote address.
|
| |
| std::string | GetRemoteHostname () const |
| | Get the remote hostname.
|
| |
| unsigned int | GetRemotePort () const |
| | Get the remote port number.
|
| |
| std::string | GetRemoteURI () const |
| | Get the remote URI.
|
| |
| bool | IsOpen () const |
| | Is the connection open?
|
| |
| void | Listen (unsigned int _port, const AcceptCallback &_acceptCB) |
| | Start a server that listens on a port.
|
| |
| void | ProcessWriteQueue () |
| | Handle on-write callbacks.
|
| |
| bool | Read (std::string &_data) |
| | Read data from the socket.
|
| |
| void | Shutdown () |
| | Shutdown the socket.
|
| |
| void | StartRead (const ReadCallback &_cb) |
| | Start a thread that reads from the connection and passes new message to the ReadCallback.
|
| |
| void | StopRead () |
| | Stop the read loop.
|
| |
|
| static bool | ValidateIP (const std::string &_ip) |
| | Return true if the _ip is a valid.
|
| |
Single TCP/IP connection manager.
The signature of a connection accept callback.
The signature of a connection read callback.
| gazebo::transport::Connection::Connection |
( |
| ) |
|
| virtual gazebo::transport::Connection::~Connection |
( |
| ) |
|
|
virtual |
template<typename Handler >
| void gazebo::transport::Connection::AsyncRead |
( |
Handler |
_handler | ) |
|
|
inline |
| void gazebo::transport::Connection::Cancel |
( |
| ) |
|
Cancel all async operations on an open socket.
| bool gazebo::transport::Connection::Connect |
( |
const std::string & |
_host, |
|
|
unsigned int |
_port |
|
) |
| |
Connect to a remote host.
- Parameters
-
| [in] | _host | The host to connect to |
| [in] | _port | The port to connect to |
- Returns
- true if connection succeeded, false otherwise
| event::ConnectionPtr gazebo::transport::Connection::ConnectToShutdown |
( |
boost::function< void()> |
_subscriber | ) |
|
|
inline |
Register a function to be called when the connection is shut down.
- Parameters
-
| [in] | _subscriber | Function to be called |
- Returns
- Handle that can be used to unregister the function
References gazebo::event::EventT< T >::Connect().
| void gazebo::transport::Connection::EnqueueMsg |
( |
const std::string & |
_buffer, |
|
|
bool |
_force = false |
|
) |
| |
Write data to the socket.
- Parameters
-
| [in] | _buffer | Data to write |
| [in] | _force | If true, block until the data has been written to the socket, otherwise just enqueue the data for asynchronous write |
| unsigned int gazebo::transport::Connection::GetId |
( |
| ) |
const |
Get the ID of the connection.
- Returns
- The connection's unique ID.
| std::string gazebo::transport::Connection::GetLocalAddress |
( |
| ) |
const |
Get the local address of this connection.
- Returns
- The local address
| std::string gazebo::transport::Connection::GetLocalHostname |
( |
| ) |
const |
Get the local hostname.
- Returns
- The local hostname
| unsigned int gazebo::transport::Connection::GetLocalPort |
( |
| ) |
const |
Get the port of this connection.
- Returns
- The local port
| std::string gazebo::transport::Connection::GetLocalURI |
( |
| ) |
const |
Get the local URI.
- Returns
- The local URI
| std::string gazebo::transport::Connection::GetRemoteAddress |
( |
| ) |
const |
Get the remote address.
- Returns
- The remote address
| std::string gazebo::transport::Connection::GetRemoteHostname |
( |
| ) |
const |
Get the remote hostname.
- Returns
- The remote hostname
| unsigned int gazebo::transport::Connection::GetRemotePort |
( |
| ) |
const |
Get the remote port number.
- Returns
- The remote port
| std::string gazebo::transport::Connection::GetRemoteURI |
( |
| ) |
const |
Get the remote URI.
- Returns
- The remote URI
| bool gazebo::transport::Connection::IsOpen |
( |
| ) |
const |
Is the connection open?
- Returns
- true if the connection is open; false otherwise
Referenced by AsyncRead().
| void gazebo::transport::Connection::Listen |
( |
unsigned int |
_port, |
|
|
const AcceptCallback & |
_acceptCB |
|
) |
| |
Start a server that listens on a port.
- Parameters
-
| [in] | _port | The port to listen on |
| [in] | _acceptCB | The callback to invoke when a new connection has been accepted |
| void gazebo::transport::Connection::ProcessWriteQueue |
( |
| ) |
|
Handle on-write callbacks.
| bool gazebo::transport::Connection::Read |
( |
std::string & |
_data | ) |
|
Read data from the socket.
- Parameters
-
| [out] | _data | Destination for data that is read |
- Returns
- true if data was successfully read, false otherwise
| void gazebo::transport::Connection::Shutdown |
( |
| ) |
|
| void gazebo::transport::Connection::StartRead |
( |
const ReadCallback & |
_cb | ) |
|
Start a thread that reads from the connection and passes new message to the ReadCallback.
- Parameters
-
| [in] | _cb | The callback to invoke when a new message is received |
| void gazebo::transport::Connection::StopRead |
( |
| ) |
|
| static bool gazebo::transport::Connection::ValidateIP |
( |
const std::string & |
_ip | ) |
|
|
static |
Return true if the _ip is a valid.
- Parameters
-
| [in] | _ip | Dotted quad to validate. |
- Returns
- True if the _ip is a valid.
The documentation for this class was generated from the following file: