Package rospy :: Package impl :: Module tcpros_base :: Class TCPROSTransport

Class TCPROSTransport

source code

         object --+    
                  |    
transport.Transport --+
                      |
                     TCPROSTransport

Generic implementation of TCPROS exchange routines for both topics and services

Instance Methods
 
__init__(self, protocol, name, header=None)
ctor
source code
 
set_socket(self, sock, endpoint_id)
Set the socket for this transport
source code
 
connect(self, dest_addr, dest_port, endpoint_id, timeout=None)
Establish TCP connection to the specified address/port.
source code
 
write_header(self)
Writes the TCPROS header to the active connection.
source code
 
read_header(self)
Read TCPROS header from active socket @raise TransportInitError if header fails to validate
source code
 
send_message(self, msg, seq)
Convenience routine for services to send a message across a particular connection.
source code
 
write_data(self, data)
Write raw data to transport
source code
[Msg]
receive_once(self)
block until messages are read off of socket
source code
 
receive_loop(self, msgs_callback)
Receive messages until shutdown
source code
 
close(self)
close i/o and release resources
source code
 
set_cleanup_callback(self, cleanup_callback) (Inherited from rospy.impl.transport.Transport) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  transport_type = 'TCPROS'
Properties

Inherited from object: __class__

Method Details

__init__(self, protocol, name, header=None)
(Constructor)

source code 

ctor

Parameters:
  • name, str - identifier @param protocol TCPROSTransportProtocol protocol implementation
  • header, dict - (optional) handshake header if transport handshake header was already read off of transport. @raise TransportInitError if transport cannot be initialized according to arguments
Overrides: object.__init__

set_socket(self, sock, endpoint_id)

source code 

Set the socket for this transport

Parameters:
  • sock (socket.socket) - socket
  • endpoint_id (str) - identifier for connection endpoint
Raises:

connect(self, dest_addr, dest_port, endpoint_id, timeout=None)

source code 

Establish TCP connection to the specified address/port. connect() always calls write_header() and read_header() after the connection is made

Parameters:
  • dest_addr (str) - destination IP address
  • dest_port (int) - destination port
  • endpoint_id (str) - string identifier for connection (for statistics)
  • timeout (float) - (optional keyword) timeout in seconds
Raises:

send_message(self, msg, seq)

source code 

Convenience routine for services to send a message across a particular connection. NOTE: write_data is much more efficient if same message is being sent to multiple connections. Not threadsafe.

Parameters:
  • msg (Msg) - message to send
  • seq (int) - sequence number for message
Raises:

write_data(self, data)

source code 

Write raw data to transport

Raises:
  • TransportInitialiationError - could not be initialized
  • TransportTerminated - no longer open for publishing
Overrides: transport.Transport.write_data

receive_once(self)

source code 

block until messages are read off of socket

Returns: [Msg]
list of newly received messages
Raises:

receive_loop(self, msgs_callback)

source code 

Receive messages until shutdown

Parameters:
  • msgs_callback (fn([msg])) - callback to invoke for new messages received

close(self)

source code 

close i/o and release resources

Overrides: transport.Transport.close