TCPROS transport. More...
#include <transport_tcp.h>
Public Types | |
typedef boost::function< void(const TransportTCPPtr &)> | AcceptCallback |
enum | Flags { SYNCHRONOUS = 1<<0 } |
Public Types inherited from ros::Transport | |
typedef boost::function< void(const TransportPtr &)> | Callback |
Public Member Functions | |
TransportTCPPtr | accept () |
Accept a connection on a server socket. Blocks until a connection is available. More... | |
virtual void | close () |
Close this transport. Once this call has returned, writing on this transport should always return an error. More... | |
bool | connect (const std::string &host, int port) |
Connect to a remote host. More... | |
virtual void | disableRead () |
Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets. More... | |
virtual void | disableWrite () |
Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets. More... | |
virtual void | enableRead () |
Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets. More... | |
virtual void | enableWrite () |
Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets. More... | |
std::string | getClientURI () |
Returns the URI of the remote host. More... | |
const std::string & | getConnectedHost () |
int | getConnectedPort () |
int | getLocalPort () |
int | getServerPort () |
Returns the port this transport is listening on. More... | |
virtual std::string | getTransportInfo () |
Returns a string description of both the type of transport and who the transport is connected to. More... | |
virtual const char * | getType () |
Return a string that details the type of transport (Eg. TCPROS) More... | |
bool | listen (int port, int backlog, const AcceptCallback &accept_cb) |
Start a server socket and listen on a port. More... | |
virtual void | parseHeader (const Header &header) |
Provides an opportunity for transport-specific options to come in through the header. More... | |
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. More... | |
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. More... | |
virtual | ~TransportTCP () |
Public Member Functions inherited from ros::Transport | |
virtual bool | requiresHeader () |
Returns a boolean to indicate if the transport mechanism is reliable or not. More... | |
void | setDisconnectCallback (const Callback &cb) |
Set the function to call when this transport has disconnected, either through a call to close(). Or a disconnect from the remote host. More... | |
void | setReadCallback (const Callback &cb) |
Set the function to call when there is data available to be read by this transport. More... | |
void | setWriteCallback (const Callback &cb) |
Set the function to call when there is space available to write on this transport. More... | |
Transport () | |
virtual | ~Transport () |
Static Public Attributes | |
static bool | s_use_ipv6_ = false |
static bool | s_use_keepalive_ = true |
Private Member Functions | |
bool | initializeSocket () |
Initializes the assigned socket – sets it to non-blocking and enables reading. More... | |
bool | setNonBlocking () |
bool | setSocket (int sock) |
Set the socket to be used by this transport. More... | |
void | socketUpdate (int events) |
Private Attributes | |
AcceptCallback | accept_cb_ |
bool | async_connected_ |
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_ |
socklen_t | la_len_ |
sockaddr_storage | local_address_ |
int | local_port_ |
PollSet * | poll_set_ |
socklen_t | sa_len_ |
sockaddr_storage | server_address_ |
int | server_port_ |
socket_fd_t | sock_ |
Additional Inherited Members | |
Protected Member Functions inherited from ros::Transport | |
bool | isHostAllowed (const std::string &host) const |
returns true if the transport is allowed to connect to the host passed to it. More... | |
bool | isOnlyLocalhostAllowed () const |
returns true if this transport is only allowed to talk to localhost More... | |
Protected Attributes inherited from ros::Transport | |
Callback | disconnect_cb_ |
Callback | read_cb_ |
Callback | write_cb_ |
TCPROS transport.
Definition at line 56 of file transport_tcp.h.
typedef boost::function<void(const TransportTCPPtr&)> ros::TransportTCP::AcceptCallback |
Definition at line 84 of file transport_tcp.h.
Enumerator | |
---|---|
SYNCHRONOUS |
Definition at line 63 of file transport_tcp.h.
ros::TransportTCP::TransportTCP | ( | PollSet * | poll_set, |
int | flags = 0 |
||
) |
Definition at line 54 of file transport_tcp.cpp.
|
virtual |
Definition at line 69 of file transport_tcp.cpp.
TransportTCPPtr ros::TransportTCP::accept | ( | ) |
Accept a connection on a server socket. Blocks until a connection is available.
Definition at line 669 of file transport_tcp.cpp.
|
virtual |
Close this transport. Once this call has returned, writing on this transport should always return an error.
Implements ros::Transport.
Definition at line 439 of file transport_tcp.cpp.
bool ros::TransportTCP::connect | ( | const std::string & | host, |
int | port | ||
) |
Connect to a remote host.
host | The hostname/IP to connect to |
port | The port to connect to |
Definition at line 230 of file transport_tcp.cpp.
|
virtual |
Disable reading on this transport. Allows derived classes to, for example, disable read polling for asynchronous sockets.
Implements ros::Transport.
Definition at line 609 of file transport_tcp.cpp.
|
virtual |
Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets.
Implements ros::Transport.
Definition at line 649 of file transport_tcp.cpp.
|
virtual |
Enable reading on this transport. Allows derived classes to, for example, enable read polling for asynchronous sockets.
Implements ros::Transport.
Definition at line 589 of file transport_tcp.cpp.
|
virtual |
Enable writing on this transport. Allows derived classes to, for example, enable write polling for asynchronous sockets.
Implements ros::Transport.
Definition at line 629 of file transport_tcp.cpp.
std::string ros::TransportTCP::getClientURI | ( | ) |
Returns the URI of the remote host.
Definition at line 769 of file transport_tcp.cpp.
|
inline |
Definition at line 105 of file transport_tcp.h.
|
inline |
Definition at line 106 of file transport_tcp.h.
|
inline |
Definition at line 100 of file transport_tcp.h.
|
inline |
Returns the port this transport is listening on.
Definition at line 99 of file transport_tcp.h.
|
virtual |
Returns a string description of both the type of transport and who the transport is connected to.
Implements ros::Transport.
Definition at line 762 of file transport_tcp.cpp.
|
inlinevirtual |
Return a string that details the type of transport (Eg. TCPROS)
Implements ros::Transport.
Definition at line 123 of file transport_tcp.h.
|
private |
Initializes the assigned socket – sets it to non-blocking and enables reading.
Definition at line 95 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.
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 372 of file transport_tcp.cpp.
|
virtual |
Provides an opportunity for transport-specific options to come in through the header.
Reimplemented from ros::Transport.
Definition at line 159 of file transport_tcp.cpp.
|
virtual |
Read a number of bytes into the supplied buffer. Not guaranteed to actually read that number of bytes.
buffer | Buffer to read from |
size | Size, in bytes, to read |
Implements ros::Transport.
Definition at line 485 of file transport_tcp.cpp.
void ros::TransportTCP::setKeepAlive | ( | bool | use, |
uint32_t | idle, | ||
uint32_t | interval, | ||
uint32_t | count | ||
) |
Definition at line 179 of file transport_tcp.cpp.
void ros::TransportTCP::setNoDelay | ( | bool | nodelay | ) |
Definition at line 169 of file transport_tcp.cpp.
|
private |
Definition at line 80 of file transport_tcp.cpp.
|
private |
Set the socket to be used by this transport.
sock | A valid TCP socket |
Definition at line 74 of file transport_tcp.cpp.
|
private |
Definition at line 696 of file transport_tcp.cpp.
|
virtual |
Write a number of bytes from the supplied buffer. Not guaranteed to actually write that number of bytes.
buffer | Buffer to write from |
size | Size, in bytes, to write |
Implements ros::Transport.
Definition at line 540 of file transport_tcp.cpp.
|
private |
Definition at line 158 of file transport_tcp.h.
|
private |
Definition at line 143 of file transport_tcp.h.
|
private |
Definition at line 160 of file transport_tcp.h.
|
private |
Definition at line 145 of file transport_tcp.h.
|
private |
Definition at line 144 of file transport_tcp.h.
|
private |
Definition at line 165 of file transport_tcp.h.
|
private |
Definition at line 166 of file transport_tcp.h.
|
private |
Definition at line 147 of file transport_tcp.h.
|
private |
Definition at line 148 of file transport_tcp.h.
|
private |
Definition at line 163 of file transport_tcp.h.
|
private |
Definition at line 150 of file transport_tcp.h.
|
private |
Definition at line 154 of file transport_tcp.h.
|
private |
Definition at line 153 of file transport_tcp.h.
|
private |
Definition at line 157 of file transport_tcp.h.
|
private |
Definition at line 162 of file transport_tcp.h.
|
static |
Definition at line 60 of file transport_tcp.h.
|
static |
Definition at line 59 of file transport_tcp.h.
|
private |
Definition at line 152 of file transport_tcp.h.
|
private |
Definition at line 151 of file transport_tcp.h.
|
private |
Definition at line 156 of file transport_tcp.h.
|
private |
Definition at line 142 of file transport_tcp.h.