Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
roswrap::TransportUDP Class Reference

UDPROS transport. More...

#include <transport_udp.h>

Inheritance diagram for roswrap::TransportUDP:
Inheritance graph
[legend]

Public Types

enum  Flags { SYNCHRONOUS = 1<<0 }
 
- Public Types inherited from roswrap::Transport
typedef std::function< void(const TransportPtr &)> Callback
 

Public Member Functions

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, int conn_id)
 Connect to a remote host. More...
 
bool createIncoming (int port, bool is_server)
 Start a server socket and listen on a port. More...
 
TransportUDPPtr createOutgoing (std::string host, int port, int conn_id, int max_datagram_size)
 Create a connection to a server socket. 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...
 
int getMaxDatagramSize () const
 
int getServerPort () const
 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...
 
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...
 
virtual bool requiresHeader ()
 Returns a boolean to indicate if the transport mechanism is reliable or not. More...
 
 TransportUDP (PollSet *poll_set, int flags=0, int max_datagram_size=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 ~TransportUDP ()
 
- Public Member Functions inherited from roswrap::Transport
virtual void parseHeader (const Header &header)
 Provides an opportunity for transport-specific options to come in through the header. 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 ()
 

Private Member Functions

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

Private Attributes

std::string cached_remote_host_
 
std::mutex close_mutex_
 
bool closed_
 
uint32_t connection_id_
 
uint8_t current_message_id_
 
uint8_t * data_buffer_
 
uint32_t data_filled_
 
uint8_t * data_start_
 
bool expecting_read_
 
bool expecting_write_
 
int flags_
 
bool is_server_
 
uint16_t last_block_
 
sockaddr_in local_address_
 
int local_port_
 
uint32_t max_datagram_size_
 
PollSetpoll_set_
 
uint8_t * reorder_buffer_
 
uint32_t reorder_bytes_
 
TransportUDPHeader reorder_header_
 
uint8_t * reorder_start_
 
sockaddr_in server_address_
 
int server_port_
 
socket_fd_t sock_
 
uint16_t total_blocks_
 

Additional Inherited Members

- Protected Member Functions inherited from roswrap::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 roswrap::Transport
Callback disconnect_cb_
 
Callback read_cb_
 
Callback write_cb_
 

Detailed Description

UDPROS transport.

Definition at line 68 of file transport_udp.h.

Member Enumeration Documentation

◆ Flags

Enumerator
SYNCHRONOUS 

Definition at line 71 of file transport_udp.h.

Constructor & Destructor Documentation

◆ TransportUDP()

roswrap::TransportUDP::TransportUDP ( PollSet poll_set,
int  flags = 0,
int  max_datagram_size = 0 
)

◆ ~TransportUDP()

virtual roswrap::TransportUDP::~TransportUDP ( )
virtual

Member Function Documentation

◆ close()

virtual void roswrap::TransportUDP::close ( )
virtual

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

Implements roswrap::Transport.

◆ connect()

bool roswrap::TransportUDP::connect ( const std::string &  host,
int  port,
int  conn_id 
)

Connect to a remote host.

Parameters
hostThe hostname/IP to connect to
portThe port to connect to
Returns
Whether or not the connection was successful

◆ createIncoming()

bool roswrap::TransportUDP::createIncoming ( int  port,
bool  is_server 
)

Start a server socket and listen on a port.

Parameters
portThe port to listen on

◆ createOutgoing()

TransportUDPPtr roswrap::TransportUDP::createOutgoing ( std::string  host,
int  port,
int  conn_id,
int  max_datagram_size 
)

Create a connection to a server socket.

◆ disableRead()

virtual void roswrap::TransportUDP::disableRead ( )
virtual

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

Implements roswrap::Transport.

◆ disableWrite()

virtual void roswrap::TransportUDP::disableWrite ( )
virtual

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

Implements roswrap::Transport.

◆ enableRead()

virtual void roswrap::TransportUDP::enableRead ( )
virtual

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

Implements roswrap::Transport.

◆ enableWrite()

virtual void roswrap::TransportUDP::enableWrite ( )
virtual

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

Implements roswrap::Transport.

◆ getClientURI()

std::string roswrap::TransportUDP::getClientURI ( )

Returns the URI of the remote host.

◆ getMaxDatagramSize()

int roswrap::TransportUDP::getMaxDatagramSize ( ) const
inline

Definition at line 123 of file transport_udp.h.

◆ getServerPort()

int roswrap::TransportUDP::getServerPort ( ) const
inline

Returns the port this transport is listening on.

Definition at line 104 of file transport_udp.h.

◆ getTransportInfo()

virtual std::string roswrap::TransportUDP::getTransportInfo ( )
virtual

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

Implements roswrap::Transport.

◆ getType()

virtual const char* roswrap::TransportUDP::getType ( )
inlinevirtual

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

Returns
The stringified transport type

Implements roswrap::Transport.

Definition at line 121 of file transport_udp.h.

◆ initializeSocket()

bool roswrap::TransportUDP::initializeSocket ( )
private

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

◆ read()

virtual int32_t roswrap::TransportUDP::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
bufferBuffer to read from
sizeSize, in bytes, to read
Returns
The number of bytes actually read, or -1 if there was an error

Implements roswrap::Transport.

◆ requiresHeader()

virtual bool roswrap::TransportUDP::requiresHeader ( )
inlinevirtual

Returns a boolean to indicate if the transport mechanism is reliable or not.

Reimplemented from roswrap::Transport.

Definition at line 119 of file transport_udp.h.

◆ setSocket()

bool roswrap::TransportUDP::setSocket ( int  sock)
private

Set the socket to be used by this transport.

Parameters
sockA valid UDP socket
Returns
Whether setting the socket was successful

◆ socketUpdate()

void roswrap::TransportUDP::socketUpdate ( int  events)
private

◆ write()

virtual int32_t roswrap::TransportUDP::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
bufferBuffer to write from
sizeSize, in bytes, to write
Returns
The number of bytes actually written, or -1 if there was an error

Implements roswrap::Transport.

Member Data Documentation

◆ cached_remote_host_

std::string roswrap::TransportUDP::cached_remote_host_
private

Definition at line 153 of file transport_udp.h.

◆ close_mutex_

std::mutex roswrap::TransportUDP::close_mutex_
private

Definition at line 142 of file transport_udp.h.

◆ closed_

bool roswrap::TransportUDP::closed_
private

Definition at line 141 of file transport_udp.h.

◆ connection_id_

uint32_t roswrap::TransportUDP::connection_id_
private

Definition at line 158 of file transport_udp.h.

◆ current_message_id_

uint8_t roswrap::TransportUDP::current_message_id_
private

Definition at line 159 of file transport_udp.h.

◆ data_buffer_

uint8_t* roswrap::TransportUDP::data_buffer_
private

Definition at line 165 of file transport_udp.h.

◆ data_filled_

uint32_t roswrap::TransportUDP::data_filled_
private

Definition at line 167 of file transport_udp.h.

◆ data_start_

uint8_t* roswrap::TransportUDP::data_start_
private

Definition at line 166 of file transport_udp.h.

◆ expecting_read_

bool roswrap::TransportUDP::expecting_read_
private

Definition at line 144 of file transport_udp.h.

◆ expecting_write_

bool roswrap::TransportUDP::expecting_write_
private

Definition at line 145 of file transport_udp.h.

◆ flags_

int roswrap::TransportUDP::flags_
private

Definition at line 156 of file transport_udp.h.

◆ is_server_

bool roswrap::TransportUDP::is_server_
private

Definition at line 147 of file transport_udp.h.

◆ last_block_

uint16_t roswrap::TransportUDP::last_block_
private

Definition at line 161 of file transport_udp.h.

◆ local_address_

sockaddr_in roswrap::TransportUDP::local_address_
private

Definition at line 149 of file transport_udp.h.

◆ local_port_

int roswrap::TransportUDP::local_port_
private

Definition at line 151 of file transport_udp.h.

◆ max_datagram_size_

uint32_t roswrap::TransportUDP::max_datagram_size_
private

Definition at line 163 of file transport_udp.h.

◆ poll_set_

PollSet* roswrap::TransportUDP::poll_set_
private

Definition at line 155 of file transport_udp.h.

◆ reorder_buffer_

uint8_t* roswrap::TransportUDP::reorder_buffer_
private

Definition at line 169 of file transport_udp.h.

◆ reorder_bytes_

uint32_t roswrap::TransportUDP::reorder_bytes_
private

Definition at line 172 of file transport_udp.h.

◆ reorder_header_

TransportUDPHeader roswrap::TransportUDP::reorder_header_
private

Definition at line 171 of file transport_udp.h.

◆ reorder_start_

uint8_t* roswrap::TransportUDP::reorder_start_
private

Definition at line 170 of file transport_udp.h.

◆ server_address_

sockaddr_in roswrap::TransportUDP::server_address_
private

Definition at line 148 of file transport_udp.h.

◆ server_port_

int roswrap::TransportUDP::server_port_
private

Definition at line 150 of file transport_udp.h.

◆ sock_

socket_fd_t roswrap::TransportUDP::sock_
private

Definition at line 140 of file transport_udp.h.

◆ total_blocks_

uint16_t roswrap::TransportUDP::total_blocks_
private

Definition at line 160 of file transport_udp.h.


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


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:15