Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GcTcpHub Class Reference

This class runs a CAN-bus HUB listening on TCP socket using the gridconnect format. More...

#include <GcTcpHub.hxx>

Inheritance diagram for GcTcpHub:
Notifiable Atomic

Public Member Functions

 GcTcpHub (CanHubFlow *can_hub, int port)
 Constructor.
 
bool is_started ()
 
unsigned get_num_clients ()
 

Private Member Functions

void on_new_connection (int fd)
 Callback when a new connection arrives.
 
void notify () override
 Error callback from the gridconnect socket.
 
- Private Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 

Private Attributes

CanHubFlowcanHub_
 
unsigned numClients_ {0}
 How many clients are connected right now.
 
SocketListener tcpListener_
 Helper object representing the listening on the socket.
 

Detailed Description

This class runs a CAN-bus HUB listening on TCP socket using the gridconnect format.

Any new incoming connection will be wired into the same virtual CAN hub. All packets will be forwarded to every participant, without loopback.

Definition at line 46 of file GcTcpHub.hxx.

Constructor & Destructor Documentation

◆ GcTcpHub()

GcTcpHub::GcTcpHub ( CanHubFlow can_hub,
int  port 
)

Constructor.

Parameters
can_hubWhich CAN-hub should we attach the TCP gridconnect hub onto.
portTCp port number to listen on.

Definition at line 64 of file GcTcpHub.cxx.

◆ ~GcTcpHub()

GcTcpHub::~GcTcpHub ( )

Definition at line 72 of file GcTcpHub.cxx.

Member Function Documentation

◆ get_num_clients()

unsigned GcTcpHub::get_num_clients ( )
inline
Returns
currently connected client count.

Definition at line 64 of file GcTcpHub.hxx.

◆ is_started()

bool GcTcpHub::is_started ( )
inline
Returns
true of the listener is ready to accept incoming connections.

Definition at line 58 of file GcTcpHub.hxx.

◆ notify()

void GcTcpHub::notify ( )
overrideprivatevirtual

Error callback from the gridconnect socket.

This is invoked when a client disconnects.

Implements Notifiable.

Definition at line 55 of file GcTcpHub.cxx.

◆ on_new_connection()

void GcTcpHub::on_new_connection ( int  fd)
private

Callback when a new connection arrives.

Parameters
fdfiledes of the freshly established incoming connection.

Definition at line 42 of file GcTcpHub.cxx.

Member Data Documentation

◆ canHub_

CanHubFlow* GcTcpHub::canHub_
private
Parameters
can_hubWhich CAN-hub should we attach the TCP gridconnect hub onto.

Definition at line 82 of file GcTcpHub.hxx.

◆ numClients_

unsigned GcTcpHub::numClients_ {0}
private

How many clients are connected right now.

Definition at line 84 of file GcTcpHub.hxx.

◆ tcpListener_

SocketListener GcTcpHub::tcpListener_
private

Helper object representing the listening on the socket.

Definition at line 86 of file GcTcpHub.hxx.


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