Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
ClientConnection.cxx
Go to the documentation of this file.
1
36
37#include "nmranet_config.h"
38
39#include "utils/FdUtils.hxx"
40
44{
45 const bool use_select =
46 (config_gridconnect_tcp_use_select() == CONSTANT_TRUE);
47
48 // Applies kernel parameters like socket options.
50
51 fd_ = fd;
52
53 if (hub_) {
55 } else if (directHub_) {
57 std::unique_ptr<MessageSegmenter>(create_gc_message_segmenter()),
59 } else {
60 DIE("Neither hub, nor directhub given to connection client");
61 }
62}
void create_port_for_fd(DirectHubInterface< uint8_t[]> *hub, int fd, std::unique_ptr< MessageSegmenter > segmenter, Notifiable *on_error)
Creates a hub port of byte stream type reading/writing a given fd.
MessageSegmenter * create_gc_message_segmenter()
Creates a message segmenter for gridconnect data.
void create_gc_port_for_can_hub(CanHubFlow *can_hub, int fd, Notifiable *on_exit, bool use_select)
Creates a new port on a CAN hub in gridconnect format for a select-compatible file descriptor.
ByteDirectHubInterface * directHub_
DirectHub to read/write data to.
DeviceClosedNotify closedNotify_
Will be called when the descriptor experiences an error (typivcally upon device closed or connection ...
int fd_
File descriptor of the currently open device/socket.
void connection_complete(int fd)
Callback from try_connect to donate the file descriptor.
CanHubFlow * hub_
CAN hub to read-write data to.
#define CONSTANT_TRUE
We cannot compare constants to zero, so we use 1 and 2 as constant values for booleans.
#define DIE(MSG)
Unconditionally terminates the current process with a message.
Definition macros.h:143
static void optimize_fd(int fd)
For an fd that is an outgoing link, detects what kind of file descriptor this is and calls the approp...
Definition FdUtils.cxx:119