ros::TransportTCP Class Reference

TCPROS transport. More...

#include <transport_tcp.h>

Inheritance diagram for ros::TransportTCP:
Inheritance graph
[legend]

List of all members.

Public Types

typedef boost::function< void(const
TransportTCPPtr &)> 
AcceptCallback
enum  Flags { SYNCHRONOUS = 1<<0 }

Public Member Functions

TransportTCPPtr accept ()
 Accept a connection on a server socket. Blocks until a connection is available.
virtual void close ()
 Close this transport. Once this call has returned, writing on this transport should always return an error.
bool connect (const std::string &host, int port)
 Connect to a remote host.
virtual void disableRead ()
 Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets.
virtual void disableWrite ()
 Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets.
virtual void enableRead ()
 Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets.
virtual void enableWrite ()
 Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets.
std::string getClientURI ()
 Returns the URI of the remote host.
const std::string & getConnectedHost ()
int getConnectedPort ()
int getServerPort ()
 Returns the port this transport is listening on.
virtual std::string getTransportInfo ()
 Returns a string description of both the type of transport and who the transport is connected to.
virtual const char * getType ()
 Return a string that details the type of transport (Eg. TCPROS).
bool listen (int port, int backlog, const AcceptCallback &accept_cb)
 Start a server socket and listen on a port.
virtual void parseHeader (const Header &header)
 Provides an opportunity for transport-specific options to come in through the header.
virtual int32_t read (uint8_t *buffer, uint32_t size)
 Read a number of bytes into the supplied buffer. Not guaranteed to actually read that number of bytes.
void setKeepAlive (bool use, uint32_t idle, uint32_t interval, uint32_t count)
void setNoDelay (bool nodelay)
 TransportTCP (PollSet *poll_set, int flags=0)
virtual int32_t write (uint8_t *buffer, uint32_t size)
 Write a number of bytes from the supplied buffer. Not guaranteed to actually write that number of bytes.
virtual ~TransportTCP ()

Static Public Attributes

static bool s_use_keepalive_ = true

Private Member Functions

bool initializeSocket ()
 Initializes the assigned socket -- sets it to non-blocking and enables reading.
bool setNonBlocking ()
bool setSocket (int sock)
 Set the socket to be used by this transport.
void socketUpdate (int events)

Private Attributes

AcceptCallback accept_cb_
std::string cached_remote_host_
boost::recursive_mutex close_mutex_
bool closed_
std::string connected_host_
int connected_port_
bool expecting_read_
bool expecting_write_
int flags_
bool is_server_
PollSetpoll_set_
sockaddr_in server_address_
int server_port_
int sock_

Detailed Description

TCPROS transport.

Definition at line 50 of file transport_tcp.h.


Member Typedef Documentation

typedef boost::function<void(const TransportTCPPtr&)> ros::TransportTCP::AcceptCallback

Definition at line 77 of file transport_tcp.h.


Member Enumeration Documentation

Enumerator:
SYNCHRONOUS 

Definition at line 56 of file transport_tcp.h.


Constructor & Destructor Documentation

ros::TransportTCP::TransportTCP ( PollSet poll_set,
int  flags = 0 
)

Definition at line 60 of file transport_tcp.cpp.

ros::TransportTCP::~TransportTCP (  )  [virtual]

Definition at line 73 of file transport_tcp.cpp.


Member Function Documentation

TransportTCPPtr ros::TransportTCP::accept (  ) 

Accept a connection on a server socket. Blocks until a connection is available.

Definition at line 533 of file transport_tcp.cpp.

void ros::TransportTCP::close (  )  [virtual]

Close this transport. Once this call has returned, writing on this transport should always return an error.

Implements ros::Transport.

Definition at line 337 of file transport_tcp.cpp.

bool ros::TransportTCP::connect ( const std::string &  host,
int  port 
)

Connect to a remote host.

Parameters:
host The hostname/IP to connect to
port The port to connect to
Returns:
Whether or not the connection was successful

Definition at line 207 of file transport_tcp.cpp.

void ros::TransportTCP::disableRead (  )  [virtual]

Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets.

Implements ros::Transport.

Definition at line 473 of file transport_tcp.cpp.

void ros::TransportTCP::disableWrite (  )  [virtual]

Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets.

Implements ros::Transport.

Definition at line 513 of file transport_tcp.cpp.

void ros::TransportTCP::enableRead (  )  [virtual]

Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets.

Implements ros::Transport.

Definition at line 453 of file transport_tcp.cpp.

void ros::TransportTCP::enableWrite (  )  [virtual]

Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets.

Implements ros::Transport.

Definition at line 493 of file transport_tcp.cpp.

std::string ros::TransportTCP::getClientURI (  ) 

Returns the URI of the remote host.

Definition at line 631 of file transport_tcp.cpp.

const std::string& ros::TransportTCP::getConnectedHost (  )  [inline]

Definition at line 97 of file transport_tcp.h.

int ros::TransportTCP::getConnectedPort (  )  [inline]

Definition at line 98 of file transport_tcp.h.

int ros::TransportTCP::getServerPort (  )  [inline]

Returns the port this transport is listening on.

Definition at line 92 of file transport_tcp.h.

std::string ros::TransportTCP::getTransportInfo (  )  [virtual]

Returns a string description of both the type of transport and who the transport is connected to.

Implements ros::Transport.

Definition at line 626 of file transport_tcp.cpp.

virtual const char* ros::TransportTCP::getType (  )  [inline, virtual]

Return a string that details the type of transport (Eg. TCPROS).

Returns:
The stringified transport type

Implements ros::Transport.

Definition at line 115 of file transport_tcp.h.

bool ros::TransportTCP::initializeSocket (  )  [private]

Initializes the assigned socket -- sets it to non-blocking and enables reading.

Definition at line 101 of file transport_tcp.cpp.

bool ros::TransportTCP::listen ( int  port,
int  backlog,
const AcceptCallback accept_cb 
)

Start a server socket and listen on a port.

Parameters:
port The port to listen on
backlog defines the maximum length for the queue of pending connections. Identical to the backlog parameter to the listen function
accept_cb The function to call when a client socket has connected

Definition at line 297 of file transport_tcp.cpp.

void ros::TransportTCP::parseHeader ( const Header header  )  [virtual]

Provides an opportunity for transport-specific options to come in through the header.

Reimplemented from ros::Transport.

Definition at line 146 of file transport_tcp.cpp.

int32_t ros::TransportTCP::read ( uint8_t *  buffer,
uint32_t  size 
) [virtual]

Read a number of bytes into the supplied buffer. Not guaranteed to actually read that number of bytes.

Parameters:
buffer Buffer to read from
size Size, in bytes, to read
Returns:
The number of bytes actually read, or -1 if there was an error

Implements ros::Transport.

Definition at line 385 of file transport_tcp.cpp.

void ros::TransportTCP::setKeepAlive ( bool  use,
uint32_t  idle,
uint32_t  interval,
uint32_t  count 
)

Definition at line 166 of file transport_tcp.cpp.

void ros::TransportTCP::setNoDelay ( bool  nodelay  ) 

Definition at line 156 of file transport_tcp.cpp.

bool ros::TransportTCP::setNonBlocking (  )  [private]

Definition at line 84 of file transport_tcp.cpp.

bool ros::TransportTCP::setSocket ( int  sock  )  [private]

Set the socket to be used by this transport.

Parameters:
sock A valid TCP socket
Returns:
Whether setting the socket was successful

Definition at line 78 of file transport_tcp.cpp.

void ros::TransportTCP::socketUpdate ( int  events  )  [private]

Definition at line 560 of file transport_tcp.cpp.

int32_t ros::TransportTCP::write ( uint8_t *  buffer,
uint32_t  size 
) [virtual]

Write a number of bytes from the supplied buffer. Not guaranteed to actually write that number of bytes.

Parameters:
buffer Buffer to write from
size Size, in bytes, to write
Returns:
The number of bytes actually written, or -1 if there was an error

Implements ros::Transport.

Definition at line 421 of file transport_tcp.cpp.


Member Data Documentation

Definition at line 144 of file transport_tcp.h.

Definition at line 146 of file transport_tcp.h.

boost::recursive_mutex ros::TransportTCP::close_mutex_ [private]

Definition at line 136 of file transport_tcp.h.

Definition at line 135 of file transport_tcp.h.

std::string ros::TransportTCP::connected_host_ [private]

Definition at line 151 of file transport_tcp.h.

Definition at line 152 of file transport_tcp.h.

Definition at line 138 of file transport_tcp.h.

Definition at line 139 of file transport_tcp.h.

Definition at line 149 of file transport_tcp.h.

Definition at line 141 of file transport_tcp.h.

Definition at line 148 of file transport_tcp.h.

Definition at line 53 of file transport_tcp.h.

sockaddr_in ros::TransportTCP::server_address_ [private]

Definition at line 142 of file transport_tcp.h.

Definition at line 143 of file transport_tcp.h.

int ros::TransportTCP::sock_ [private]

Definition at line 134 of file transport_tcp.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


roscpp
Author(s): Morgan Quigley mquigley@cs.stanford.edu, Josh Faust jfaust@willowgarage.com, Brian Gerkey gerkey@willowgarage.com
autogenerated on Fri Jan 11 10:08:41 2013