1 #ifndef TCPSocketTransfer_hh
2 #define TCPSocketTransfer_hh
15 #include <condition_variable>
18 #include "fhiclcpp/fwd.h"
21 #include "artdaq/TransferPlugins/TransferInterface.hh"
22 #include "artdaq/TransferPlugins/detail/SRSockets.hh"
23 #include "artdaq/TransferPlugins/detail/Timeout.hh"
24 #include "artdaq-core/Data/Fragment.hh"
28 class TCPSocketTransfer;
80 CopyStatus copyFragment(Fragment& frag,
size_t timeout_usec)
override {
return sendFragment_(std::move(frag), timeout_usec); }
88 CopyStatus moveFragment(Fragment&& frag,
size_t timeout_usec)
override {
return sendFragment_(std::move(frag), timeout_usec); }
101 enum class SocketState
114 struct DestinationInfo
116 std::string hostname;
120 std::unordered_map<size_t, DestinationInfo> hostMap_;
122 volatile unsigned connect_state : 1;
123 unsigned blocking : 1;
127 bool stats_connect_stop_;
128 boost::thread stats_connect_thread_;
129 std::condition_variable stopstatscv_;
130 std::mutex stopstatscvm_;
132 bool timeoutMessageArmed_;
135 CopyStatus sendFragment_(Fragment&& frag,
size_t timeout_usec);
137 CopyStatus sendData_(
const void* buf,
size_t bytes,
size_t tmo);
139 CopyStatus sendData_(
const struct iovec* iov,
int iovcnt,
size_t tmo);
142 void stats_connect_();
155 #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.
int receiveFragmentData(RawDataType *destination, size_t wordCount) override
Receive the body of a Fragment to the given destination pointer.
TCPSocketTransfer(fhicl::ParameterSet const &ps, Role role)
TCPSocketTransfer Constructor.
int receiveFragmentHeader(detail::RawFragmentHeader &header, size_t receiveTimeout) override
Receive a Fragment Header from the transport mechanism.
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.