Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
RobotRaconteur::LocalTransport Class Reference

Transport for communication between processes using UNIX domain sockets. More...

#include <LocalTransport.h>

Inheritance diagram for RobotRaconteur::LocalTransport:
RobotRaconteur::Transport

Public Member Functions

 LocalTransport (const boost::shared_ptr< RobotRaconteurNode > &node=RobotRaconteurNode::sp())
 Construct a new LocalTransport.
virtual void StartClientAsNodeName (boost::string_ref name)
 Initialize the LocalTransport by assigning a NodeID based on NodeName.
virtual void StartServerAsNodeName (boost::string_ref name, bool public_=false)
 Start the server using the specified NodeName and assigns a NodeID.
virtual void StartServerAsNodeID (const NodeID &nodeid, bool public_=false)
 Start the server using the specified NodeID.
virtual int32_t GetMaxMessageSize ()
 Get the maximum serialized message size.
virtual void SetMaxMessageSize (int32_t size)
 Set the maximum serialized message size.
virtual bool GetDisableMessage4 ()
 Get disable Message Format Version 4.
virtual void SetDisableMessage4 (bool d)
 Set disable Message Format Version 4.
virtual bool GetDisableStringTable ()
 Get disable string table.
virtual void SetDisableStringTable (bool d)
 Set disable string table.
virtual bool GetDisableAsyncMessageIO ()
 Get if async message io is disabled.
virtual void SetDisableAsyncMessageIO (bool d)
 Set if async message io is disabled.
virtual void EnableNodeDiscoveryListening ()
 Enable node discovery listening.
virtual void DisableNodeDiscoveryListening ()
 Disable node discovery listening.

Static Public Member Functions

static bool IsLocalTransportSupported ()
 Check if the LocalTransport is supported on the current operating system.

Detailed Description

Transport for communication between processes using UNIX domain sockets.

It is recommended that ClientNodeSetup, ServerNodeSetup, or SecureServerNodeSetup be used to construct this class.

See robotraconteur_url for more information on URLs.

The LocalTransport implements transport connections between processes running on the same host operating system using UNIX domain sockets. UNIX domain sockets are similar to standard networking sockets, but are used when both peers are on the same machine instead of connected through a network. This provides faster operation and greater security, since the kernel simply passes data between the processes. UNIX domain sockets work using Information Node (inode) files, which are special files on the standard filesystem. Servers "listen" on a specified inode, and clients use the inode as the address to connect. The LocalTransport uses UNIX sockets in SOCK_STREAM mode. This provides a reliable stream transport connection similar to TCP, but with significantly improved performance due the lower overhead.

UNIX domain sockets were added to Windows 10 with the 1803 update. Robot Raconteur switch to UNIX domain sockets for the LocalTransport on Windows in version 0.9.2. Previous versions used Named Pipes, but these were inferior to UNIX sockets. The LocalTransport will not function on versions of Windows prior to Windows 10 1803 update due to the lack of support for UNIX sockets. A warning will be issued to the log if the transport is not available, and all connection attempts will fail. All other transports will continue to operate normally.

The LocalTransport stores inode and node information files in the filesystem at various operator system dependent locations. See the Robot Raconteur Standards documents for details on where these files are stored.

Discovery is implemented using file watchers. The file watchens must be activated using the node setup flags, or by calling EnableNodeDiscoveryListening(). After being initialized the file watchers operate automatically.

The LocalTransport can be used to dynamically assign NodeIDs to nodes based on a NodeName. StartServerAsNodeName() and StartClientAsNodeName() take a NodeName that will identify the node to clients, and manage a system-local NodeID corresponding to that NodeName. The generated NodeIDs are stored on the local filesystem. If LocalTransport finds a corresponding NodeID on the filesystem, it will load and use that NodeID. If it does not, a new random NodeID is automatically generated.

The server can be started in "public" or "private" mode. Private servers store their inode and information in a location only the account owner can access, while "public" servers are placed in a location that all users with the appropriate permissions can access. By default, public LocalTransport servers are assigned to the "robotraconteur" group. Clients that belong to the "robotraconteur" group will be able to connect to these public servers.

Constructor & Destructor Documentation

◆ LocalTransport()

RobotRaconteur::LocalTransport::LocalTransport ( const boost::shared_ptr< RobotRaconteurNode > & node = RobotRaconteurNode::sp())

Construct a new LocalTransport.

Must use boost::make_shared<LocalTransport>()

The use of RobotRaconteurNodeSetup and subclasses is recommended to construct transports.

The transport must be registered with the node using RobotRaconteurNode::RegisterTransport() after construction.

Parameters
nodeThe node that will use the transport. Default is the singleton node

Member Function Documentation

◆ EnableNodeDiscoveryListening()

virtual void RobotRaconteur::LocalTransport::EnableNodeDiscoveryListening ( )
virtual

Enable node discovery listening.

Starts file watchers to detect LocalTransport servers

◆ GetDisableAsyncMessageIO()

virtual bool RobotRaconteur::LocalTransport::GetDisableAsyncMessageIO ( )
virtual

Get if async message io is disabled.

Async message io has better memory handling, at the expense of slightly higher latency.

Default: Async io enabled

Returns
true Async message io is disabled
false Async message io is not disabled

◆ GetDisableMessage4()

virtual bool RobotRaconteur::LocalTransport::GetDisableMessage4 ( )
virtual

Get disable Message Format Version 4.

Message Format Version 2 will be used

Default: Message V4 is enabled

Returns
true Disable Message V4
false Enable Message V4

◆ GetDisableStringTable()

virtual bool RobotRaconteur::LocalTransport::GetDisableStringTable ( )
virtual

Get disable string table.

Default: false

RobotRaconteurNodeSetup and its subclasses will disable the string table by default

Returns
true Disable the string table
false String table is not disabled

◆ GetMaxMessageSize()

virtual int32_t RobotRaconteur::LocalTransport::GetMaxMessageSize ( )
virtual

Get the maximum serialized message size.

Default: 10 MB

Returns
int32_t The size in bytes

◆ IsLocalTransportSupported()

bool RobotRaconteur::LocalTransport::IsLocalTransportSupported ( )
static

Check if the LocalTransport is supported on the current operating system.

Windows versions before Windows 10 1803 do not support the LocalTransport due to lack of UNIX sockets. All other transports will continue to operate normally.

All versions of Linux and Mac OSX support the LocalTransport

LocalTransport on Android and iOS is not officially supported

Returns
true LocalTransport is supported
false LocalTransport is not supported

◆ SetDisableAsyncMessageIO()

virtual void RobotRaconteur::LocalTransport::SetDisableAsyncMessageIO ( bool d)
virtual

Set if async message io is disabled.

Async message io has better memory handling, at the expense of slightly higher latency.

Default: Async io enabled

Parameters
dIf true, async io is disabled

◆ SetDisableMessage4()

virtual void RobotRaconteur::LocalTransport::SetDisableMessage4 ( bool d)
virtual

Set disable Message Format Version 4.

Message Format Version 2 will be used

Default: Message V4 is enabled

Parameters
dIf true, Message V4 is disabled

◆ SetDisableStringTable()

virtual void RobotRaconteur::LocalTransport::SetDisableStringTable ( bool d)
virtual

Set disable string table.

Default: false

RobotRaconteurNodeSetup and its subclasses will disable the string table by default

Parameters
dIf true, string table is disabled

◆ SetMaxMessageSize()

virtual void RobotRaconteur::LocalTransport::SetMaxMessageSize ( int32_t size)
virtual

Set the maximum serialized message size.

Default: 10 MB

Parameters
sizeThe size in bytes

◆ StartClientAsNodeName()

virtual void RobotRaconteur::LocalTransport::StartClientAsNodeName ( boost::string_ref name)
virtual

Initialize the LocalTransport by assigning a NodeID based on NodeName.

Assigns the specified name to be the NodeName of the node, and manages a corresponding NodeID. See LocalTransport for more information.

Throws NodeNameAlreadyInUse if another node is using name

Parameters
nameThe NodeName

◆ StartServerAsNodeID()

virtual void RobotRaconteur::LocalTransport::StartServerAsNodeID ( const NodeID & nodeid,
bool public_ = false )
virtual

Start the server using the specified NodeID.

The LocalTransport will listen on a UNIX domain socket for incoming clients, using information files and inodes on the local filesystem. This function leaves the NodeName blank, so clients must use NodeID to identify the node.

Throws NodeIDAlreadyInUse if another node is using nodeid

Parameters
nodeidThe NodeID
public_If true, other users can access the server. If not, only the account owner can access the server.

◆ StartServerAsNodeName()

virtual void RobotRaconteur::LocalTransport::StartServerAsNodeName ( boost::string_ref name,
bool public_ = false )
virtual

Start the server using the specified NodeName and assigns a NodeID.

The LocalTransport will listen on a UNIX domain socket for incoming clients, using information files and inodes on the local filesystem. Clients can locate the node using the NodeID and/or NodeName. The NodeName is assigned to the node, and the transport manages a corresponding NodeID. See LocalTransport for more information.

Throws NodeNameAlreadyInUse if another node is using name

Throws NodeIDAlreadyInUse if another node is using the managed NodeID

Parameters
nameThe NodeName
public_If true, other users can access the server. If not, only the account owner can access the server.

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