All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Public Attributes | List of all members
gazebo::transport::Connection Class Reference

TCP/IP Connection. More...

#include <Connection.hh>

Inheritance diagram for gazebo::transport::Connection:
Inheritance graph
[legend]

Public Types

typedef boost::function< void(const
ConnectionPtr &)> 
AcceptCallback
 
typedef boost::function< void(const
std::string &data)> 
ReadCallback
 

Public Member Functions

 Connection ()
 Constructor.
 
virtual ~Connection ()
 Destructor.
 
template<typename Handler >
void AsyncRead (Handler handler)
 Peform and asyncronous read.
 
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_)
 
void DisconnectShutdown (event::ConnectionPtr subscriber_)
 
void EnqueueMsg (const std::string &_buffer, bool _force=false)
 Write data to the socket.
 
std::string GetLocalAddress () const
 Get the 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
 Return true if the connection is open.
 
void Listen (unsigned int port, const AcceptCallback &accept_cb)
 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.
 

Public Attributes

unsigned int id
 
unsigned int writeCount
 

Detailed Description

TCP/IP Connection.

Member Typedef Documentation

typedef boost::function<void(const ConnectionPtr&)> gazebo::transport::Connection::AcceptCallback
typedef boost::function<void(const std::string &data)> gazebo::transport::Connection::ReadCallback

Constructor & Destructor Documentation

gazebo::transport::Connection::Connection ( )

Constructor.

virtual gazebo::transport::Connection::~Connection ( )
virtual

Destructor.

Member Function Documentation

template<typename Handler >
void gazebo::transport::Connection::AsyncRead ( Handler  handler)
inline

Peform and asyncronous read.

References gzerr, HEADER_LENGTH, and IsOpen().

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.

event::ConnectionPtr gazebo::transport::Connection::ConnectToShutdown ( boost::function< void()>  subscriber_)
inline
void gazebo::transport::Connection::DisconnectShutdown ( event::ConnectionPtr  subscriber_)
inline
void gazebo::transport::Connection::EnqueueMsg ( const std::string &  _buffer,
bool  _force = false 
)

Write data to the socket.

std::string gazebo::transport::Connection::GetLocalAddress ( ) const

Get the address of this connection.

std::string gazebo::transport::Connection::GetLocalHostname ( ) const

Get the local hostname.

unsigned int gazebo::transport::Connection::GetLocalPort ( ) const

Get the port of this connection.

std::string gazebo::transport::Connection::GetLocalURI ( ) const

Get the local URI.

std::string gazebo::transport::Connection::GetRemoteAddress ( ) const

Get the remote address.

std::string gazebo::transport::Connection::GetRemoteHostname ( ) const

Get the remote hostname.

unsigned int gazebo::transport::Connection::GetRemotePort ( ) const

Get the remote port number.

std::string gazebo::transport::Connection::GetRemoteURI ( ) const

Get the remote URI.

bool gazebo::transport::Connection::IsOpen ( ) const

Return true if the connection is open.

Referenced by AsyncRead().

void gazebo::transport::Connection::Listen ( unsigned int  port,
const AcceptCallback accept_cb 
)

Start a server that listens on a port.

void gazebo::transport::Connection::ProcessWriteQueue ( )

Handle on write callbacks.

bool gazebo::transport::Connection::Read ( std::string &  data)

Read data from the socket.

void gazebo::transport::Connection::Shutdown ( )

Shutdown the socket.

void gazebo::transport::Connection::StartRead ( const ReadCallback cb)

Start a thread that reads from the connection, and passes new message to the ReadCallback.

void gazebo::transport::Connection::StopRead ( )

Stop the read loop.

Member Data Documentation

unsigned int gazebo::transport::Connection::id
unsigned int gazebo::transport::Connection::writeCount

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