1 #ifndef TCPSocketTransfer_hh
2 #define TCPSocketTransfer_hh
11 #include <sys/types.h>
22 #include <condition_variable>
25 #include "fhiclcpp/fwd.h"
28 #include "artdaq/TransferPlugins/TransferInterface.hh"
29 #include "artdaq/TransferPlugins/detail/SRSockets.hh"
30 #include "artdaq/TransferPlugins/detail/Timeout.hh"
31 #include "artdaq-core/Data/Fragment.hh"
35 class TCPSocketTransfer;
79 CopyStatus copyFragment(Fragment& frag,
size_t timeout_usec)
override {
return sendFragment_(std::move(frag), timeout_usec); }
87 CopyStatus moveFragment(Fragment&& frag,
size_t timeout_usec)
override {
return sendFragment_(std::move(frag), timeout_usec); }
100 enum class SocketState
115 struct DestinationInfo
117 std::string hostname;
121 std::unordered_map<size_t, DestinationInfo> hostMap_;
123 volatile unsigned connect_state : 1;
124 unsigned blocking : 1;
128 bool stats_connect_stop_;
129 std::thread stats_connect_thread_;
130 std::condition_variable stopstatscv_;
131 std::mutex stopstatscvm_;
133 bool timeoutMessageArmed_;
136 CopyStatus sendFragment_(Fragment&& frag,
size_t timeout_usec);
138 CopyStatus sendFragment_(
const void* buf,
size_t bytes,
size_t tmo);
140 CopyStatus sendFragment_(
const struct iovec* iov,
int iovcnt,
size_t tmo);
143 void stats_connect_();
156 #endif // TCPSocketTransfer_hh
virtual int source_rank() const
Get the source rank for this TransferInterface instance.
Role role() const
Get the TransferInterface::Role of this TransferInterface.
CopyStatus copyFragment(Fragment &frag, size_t timeout_usec) override
Copy a Fragment to the destination. Same implementation as moveFragment, as TCP is always reliable...
The Timeout class performs registered actions at specified intervals.
TCPSocketTransfer(fhicl::ParameterSet const &ps, Role role)
TCPSocketTransfer Constructor.
int receiveFragment(Fragment &frag, size_t timeout_usec=0) override
Receive a Fragment using TCP.
Role
Used to determine if a TransferInterface is a Sender or Receiver.
CopyStatus moveFragment(Fragment &&frag, size_t timeout_usec) override
Move a Fragment to the destination.
This interface defines the functions used to transfer data between artdaq applications.
virtual int destination_rank() const
Get the destination rank for this TransferInterface instance.
TransferInterface implementation plugin that sends data using TCP sockets.
This header is sent by the TCPSocket_transfer to allow for more efficient writev calls.
CopyStatus
Returned from the send functions, this enumeration describes the possible return codes. If an exception occurs, it will be thrown and should be handled normally.