TcpCore
Examples of using a TCP stream bridge are described in Using The TCP Bridge.
TcpCore objects in C++ are referenced by the following shared pointer typedef:
-
typedef std::shared_ptr<rogue::interfaces::stream::TcpCore> rogue::interfaces::stream::TcpCorePtr
Shared pointer alias for
TcpCore.
The class description is shown below:
-
class TcpCore : public rogue::interfaces::stream::Master, public rogue::interfaces::stream::Slave
Stream TCP bridge core implementation.
This class implements the core functionality of the TcpClient and TcpServer classes which implement a Rogue stream bridge over a TCP network. This core can operate in either client or server mode. The TcpClient and TcpServer classes are thin wrappers that define which mode flag to pass to this base class.
The TcpServer and TcpClient interfaces are blocking and will stall frame transmissions when the remote side is either not present or is back-pressuring. When the remote server is not present a local buffer is not utilized, where it is utilized when a connection has been established.
Subclassed by rogue::interfaces::stream::TcpClient, rogue::interfaces::stream::TcpServer
Public Functions
-
TcpCore(const std::string &addr, uint16_t port, bool server)
Constructs a TCP stream bridge core.
This constructor is a low-level C++ allocation path. Prefer
create()when shared ownership or Python exposure is required.The constructor takes an address, port, and server mode flag. The address can be an IP address or hostname. In server mode, the address selects the local interface to bind. A value of
"*"binds all local interfaces.The stream bridge uses two consecutive TCP ports;
portis the base. For example,port=8000uses ports8000and8001.- Parameters:
addr – Interface address for server, remote server address for client.
port – Base TCP port number.
server – Set to
trueto run in server mode.
-
~TcpCore()
Destroys the bridge core and releases resources.
-
void close()
Closes active bridge connections.
-
virtual void stop()
Stops the interface and worker thread.
Receives a frame from upstream and forwards over the TCP bridge.
- Parameters:
frame – Incoming stream frame.
Public Static Functions
-
static std::shared_ptr<rogue::interfaces::stream::TcpCore> create(const std::string &addr, uint16_t port, bool server)
Creates a TCP stream bridge core instance and returns it as
TcpCorePtr.Parameter semantics are identical to the constructor; see
TcpCore()for address and port behavior details. This static factory is the preferred construction path when the object is shared across Rogue graph connections or exposed to Python. It returnsstd::shared_ptrownership compatible with Rogue pointer typedefs. Not exposed to Python.- Parameters:
addr – Interface address for server, remote server address for client.
port – Base TCP port number.
server – Set to
trueto run in server mode.
- Returns:
Shared pointer to the created bridge core.
-
static void setup_python()
Registers this type with Python bindings.
-
TcpCore(const std::string &addr, uint16_t port, bool server)