tdaq-develop-2025-02-12
TCPTransmitterSocket.h
1 #ifndef _ots_TCPTransmitterSocket_h_
2 #define _ots_TCPTransmitterSocket_h_
3 
4 #include "otsdaq/NetworkUtilities/TCPSocket.h"
5 
6 #include <cstdint>
7 #include <iostream>
8 #include <string>
9 #include <vector>
10 
11 namespace ots
12 {
14 class TCPTransmitterSocket : public virtual TCPSocket
15 {
16  public:
17  TCPTransmitterSocket(int socketId = invalidSocketId);
18  virtual ~TCPTransmitterSocket(void);
19  // TCPTransmitterSocket(TCPTransmitterSocket const&) = delete ;
20  TCPTransmitterSocket(TCPTransmitterSocket&& theTCPTransmitterSocket) = default;
21 
22  void send(char const* buffer, std::size_t size, bool forceEmptyPacket = false);
23  void send(const std::string& buffer);
24  void send(const std::vector<char>& buffer);
25  void send(const std::vector<uint16_t>& buffer);
26 
27  template<typename T>
28  void send(const std::vector<T>& buffer)
29  {
30  send(reinterpret_cast<const char*>(&buffer.at(0)), buffer.size() * sizeof(T));
31  }
32 
33  void sendPacket(char const* buffer, std::size_t size);
34  void sendPacket(const std::string& buffer);
35  void setSendTimeout(unsigned int timeoutSeconds, unsigned int timeoutMicroSeconds);
36 };
37 } // namespace ots
38 #endif
A class that can write to a socket.