otsdaq  3.09.00
TransceiverSocket.h
1 #ifndef _ots_TransceiverSocket_h_
2 #define _ots_TransceiverSocket_h_
3 
4 #include "otsdaq/NetworkUtilities/ReceiverSocket.h"
5 #include "otsdaq/NetworkUtilities/TransmitterSocket.h"
6 
7 #include <string>
8 #include <vector>
9 
10 namespace ots
11 {
13 {
14  public:
15  TransceiverSocket(std::string IPAddress, unsigned int port = 0);
16  virtual ~TransceiverSocket(void);
17 
21  int acknowledge(const std::string& buffer,
22  bool verbose = false,
23  size_t maxChunkSize = 1500,
24  unsigned int interPacketGapUSeconds = 0,
25  bool enableRetransmission = false);
26 
40  int sendAll(const std::string& buffer,
41  bool verbose = false,
42  size_t maxChunkSize = 65500,
43  unsigned int interPacketGapUSeconds = 0);
44 
50  int receiveAll(std::string& buffer,
51  unsigned int timeoutSeconds = 5,
52  unsigned int retransmitMaxRetries = 10,
53  bool verbose = false);
54 
55  std::string sendAndReceive(Socket& toSocket,
56  const std::string& sendBuffer,
57  unsigned int timeoutSeconds = 1,
58  unsigned int timeoutUSeconds = 0,
59  bool verbose = false,
60  unsigned int interPacketTimeoutUSeconds = 10000);
61 
70  std::string sendAndReceiveAll(Socket& toSocket,
71  const std::string& sendBuffer,
72  unsigned int timeoutSeconds = 5,
73  unsigned int retransmitMaxRetries = 10,
74  bool verbose = false);
75 
77  static constexpr uint16_t RETRANSMIT_MAGIC = 0xD2C4;
78  static constexpr size_t RETRANSMIT_HEADER_SIZE = 8;
79 
80  protected:
81  TransceiverSocket(void);
82 
83  private:
84  std::mutex sendAndReceiveMutex_;
85 };
86 
87 } // namespace ots
88 
89 #endif
int acknowledge(const std::string &buffer, bool verbose=false, size_t maxChunkSize=1500, unsigned int interPacketGapUSeconds=0, bool enableRetransmission=false)
std::string sendAndReceiveAll(Socket &toSocket, const std::string &sendBuffer, unsigned int timeoutSeconds=5, unsigned int retransmitMaxRetries=10, bool verbose=false)
static constexpr uint16_t RETRANSMIT_MAGIC
Retransmission protocol constants.
int sendAll(const std::string &buffer, bool verbose=false, size_t maxChunkSize=65500, unsigned int interPacketGapUSeconds=0)
std::string sendAndReceive(Socket &toSocket, const std::string &sendBuffer, unsigned int timeoutSeconds=1, unsigned int timeoutUSeconds=0, bool verbose=false, unsigned int interPacketTimeoutUSeconds=10000)
int receiveAll(std::string &buffer, unsigned int timeoutSeconds=5, unsigned int retransmitMaxRetries=10, bool verbose=false)
defines used also by OtsConfigurationWizardSupervisor