|
Robot Raconteur Core C++ Library
|
Transport for communication between processes using UNIX domain sockets. More...
#include <LocalTransport.h>
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. | |
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.
| 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.
| node | The node that will use the transport. Default is the singleton node |
|
virtual |
Enable node discovery listening.
Starts file watchers to detect LocalTransport servers
|
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
|
virtual |
Get disable Message Format Version 4.
Message Format Version 2 will be used
Default: Message V4 is enabled
|
virtual |
Get disable string table.
Default: false
RobotRaconteurNodeSetup and its subclasses will disable the string table by default
|
virtual |
Get the maximum serialized message size.
Default: 10 MB
|
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
|
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
| d | If true, async io is disabled |
|
virtual |
Set disable Message Format Version 4.
Message Format Version 2 will be used
Default: Message V4 is enabled
| d | If true, Message V4 is disabled |
|
virtual |
Set disable string table.
Default: false
RobotRaconteurNodeSetup and its subclasses will disable the string table by default
| d | If true, string table is disabled |
|
virtual |
Set the maximum serialized message size.
Default: 10 MB
| size | The size in bytes |
|
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
| name | The NodeName |
|
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
| nodeid | The NodeID |
| public_ | If true, other users can access the server. If not, only the account owner can access the server. |
|
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
| name | The NodeName |
| public_ | If true, other users can access the server. If not, only the account owner can access the server. |