artdaq  v3_07_01
artdaq::TCPSocketTransfer Class Reference

TransferInterface implementation plugin that sends data using TCP sockets. More...

#include <artdaq/TransferPlugins/TCPSocketTransfer.hh>

Inheritance diagram for artdaq::TCPSocketTransfer:
artdaq::TransferInterface

Public Member Functions

 TCPSocketTransfer (fhicl::ParameterSet const &ps, Role role)
 TCPSocketTransfer Constructor. More...
 
int receiveFragmentHeader (detail::RawFragmentHeader &header, size_t receiveTimeout) override
 Receive a Fragment Header from the transport mechanism. More...
 
int receiveFragmentData (RawDataType *destination, size_t wordCount) override
 Receive the body of a Fragment to the given destination pointer. More...
 
CopyStatus transfer_fragment_min_blocking_mode (Fragment const &frag, size_t timeout_usec) override
 Transfer a Fragment to the destination. May not necessarily be reliable, but will not block longer than send_timeout_usec. More...
 
CopyStatus transfer_fragment_reliable_mode (Fragment &&frag) override
 Transfer a Fragment to the destination. This should be reliable, if the underlying transport mechanism supports reliable sending. More...
 
bool isRunning () override
 Determine whether the TransferInterface plugin is able to send/receive data. More...
 
void flush_buffers () override
 Flush any in-flight data. This should be used by the receiver after the receive loop has ended.
 
- Public Member Functions inherited from artdaq::TransferInterface
 TransferInterface (const fhicl::ParameterSet &ps, Role role)
 TransferInterface Constructor. More...
 
 TransferInterface (const TransferInterface &)=delete
 Copy Constructor is deleted.
 
TransferInterfaceoperator= (const TransferInterface &)=delete
 Copy Assignment operator is deleted. More...
 
virtual ~TransferInterface ()=default
 Default virtual Destructor.
 
virtual int receiveFragment (artdaq::Fragment &fragment, size_t receiveTimeout)
 Receive a Fragment from the transport mechanism. More...
 
virtual CopyStatus transfer_fragment_min_blocking_mode (artdaq::Fragment const &fragment, size_t send_timeout_usec)=0
 Transfer a Fragment to the destination. May not necessarily be reliable, but will not block longer than send_timeout_usec. More...
 
virtual CopyStatus transfer_fragment_reliable_mode (artdaq::Fragment &&fragment)=0
 Transfer a Fragment to the destination. This should be reliable, if the underlying transport mechanism supports reliable sending. More...
 
std::string uniqueLabel () const
 Get the unique label of this TransferInterface instance. More...
 
virtual int source_rank () const
 Get the source rank for this TransferInterface instance. More...
 
virtual int destination_rank () const
 Get the destination rank for this TransferInterface instance. More...
 

Additional Inherited Members

- Public Types inherited from artdaq::TransferInterface
enum  ReceiveReturnCode : int { DATA_END = -2222, RECV_TIMEOUT = -1111, NO_RANK_INFO = -1, RECV_SUCCESS = 0 }
 Return codes from receive operations More...
 
enum  Role { Role::kSend, Role::kReceive }
 Used to determine if a TransferInterface is a Sender or Receiver. More...
 
enum  CopyStatus { CopyStatus::kSuccess, CopyStatus::kTimeout, CopyStatus::kErrorNotRequiringException }
 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. More...
 
using Parameters = fhicl::WrappedTable< Config >
 Used for ParameterSet validation (if desired)
 
- Static Public Member Functions inherited from artdaq::TransferInterface
static std::string CopyStatusToString (CopyStatus in)
 Convert a CopyStatus variable to its string represenatation More...
 
- Protected Member Functions inherited from artdaq::TransferInterface
Role role () const
 Get the TransferInterface::Role of this TransferInterface. More...
 
- Protected Attributes inherited from artdaq::TransferInterface
const Role role_
 Whether this instance of TransferInterface is a sender or receiver.
 
const int source_rank_
 Rank of source.
 
const int destination_rank_
 Rank of destination.
 
const std::string unique_label_
 Unique label of transfer (ideally the same on sender and receiver)
 
size_t buffer_count_
 The number of Fragment transfers the TransferInterface can handle simultaneously.
 
const size_t max_fragment_size_words_
 The maximum size of the transferred Fragment objects, in artdaq::Fragment::RawDataType words.
 

Detailed Description

TransferInterface implementation plugin that sends data using TCP sockets.

Definition at line 39 of file TCPSocketTransfer.hh.

Constructor & Destructor Documentation

artdaq::TCPSocketTransfer::TCPSocketTransfer ( fhicl::ParameterSet const &  ps,
TransferInterface::Role  role 
)

TCPSocketTransfer Constructor.

Parameters
psParameterSet used to configure TCPSocketTransfer
roleRole of this TCPSocketTransfer instance (kSend or kReceive)
* TCPSocketTransfer accepts the following Parameters:
* "tcp_receive_buffer_size" (Default: 0): The TCP buffer size on the receive socket
* "send_retry_timeout_us" (Default: 1000000): Microseconds between send retries (infinite retries for moveFragment, up to send_timeout_us for copyFragment)
* "host_map" (REQUIRED): List of FHiCL tables containing information about other hosts in the system.
*   Each table should contain:
*   "rank" (Default: RECV_TIMEOUT): Rank of this host
*   "host" (Default: "localhost"): Hostname of this host
*   "portOffset" (Default: 5500): To avoid collisions, each destination should specify its own port offset.
*     All TCPSocketTransfers sending to that destination will add their own rank to make a unique port number.
* 

TCPSocketTransfer also requires all Parameters for configuring a TransferInterface

Definition at line 43 of file TCPSocket_transfer.cc.

Member Function Documentation

bool artdaq::TCPSocketTransfer::isRunning ( )
overridevirtual

Determine whether the TransferInterface plugin is able to send/receive data.

Returns
True if the TransferInterface plugin is currently able to send/receive data

Reimplemented from artdaq::TransferInterface.

Definition at line 580 of file TCPSocket_transfer.cc.

int artdaq::TCPSocketTransfer::receiveFragmentData ( RawDataType *  destination,
size_t  wordCount 
)
overridevirtual

Receive the body of a Fragment to the given destination pointer.

Parameters
destinationPointer to memory region where Fragment data should be stored
wordCountNumber of RawDataType words to receive
Returns
The rank the Fragment was received from (should be source_rank), or RECV_TIMEOUT

Implements artdaq::TransferInterface.

Definition at line 387 of file TCPSocket_transfer.cc.

int artdaq::TCPSocketTransfer::receiveFragmentHeader ( detail::RawFragmentHeader &  header,
size_t  receiveTimeout 
)
overridevirtual

Receive a Fragment Header from the transport mechanism.

Parameters
[out]headerReceived Fragment Header
receiveTimeoutTimeout for receive
Returns
The rank the Fragment was received from (should be source_rank), or RECV_TIMEOUT

Implements artdaq::TransferInterface.

Definition at line 125 of file TCPSocket_transfer.cc.

CopyStatus artdaq::TCPSocketTransfer::transfer_fragment_min_blocking_mode ( Fragment const &  frag,
size_t  timeout_usec 
)
inlineoverride

Transfer a Fragment to the destination. May not necessarily be reliable, but will not block longer than send_timeout_usec.

Parameters
fragFragment to transfer
timeout_usecTimeout for send, in microseconds
Returns
CopyStatus detailing result of transfer

Definition at line 86 of file TCPSocketTransfer.hh.

CopyStatus artdaq::TCPSocketTransfer::transfer_fragment_reliable_mode ( Fragment &&  frag)
inlineoverride

Transfer a Fragment to the destination. This should be reliable, if the underlying transport mechanism supports reliable sending.

Parameters
fragFragment to transfer
Returns
CopyStatus detailing result of copy

Definition at line 93 of file TCPSocketTransfer.hh.


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