1 #include "otsdaq/NetworkUtilities/TransceiverSocket.h"
2 #include "otsdaq/Macros/CoutMacros.h"
3 #include "otsdaq/MessageFacility/MessageFacility.h"
10 TransceiverSocket::TransceiverSocket(
void) { __COUT__ <<
"TransceiverSocket constructor " << __E__; }
13 TransceiverSocket::TransceiverSocket(std::string IPAddress,
unsigned int port) :
Socket(IPAddress, port)
15 __COUT__ <<
"TransceiverSocket constructor " << IPAddress <<
":" << port << __E__;
19 TransceiverSocket::~TransceiverSocket(
void) {}
23 int TransceiverSocket::acknowledge(
const std::string& buffer,
bool verbose)
26 std::lock_guard<std::mutex> lock(sendMutex_);
29 __COUT__ <<
"Acknowledging on Socket Descriptor #: " << socketNumber_ <<
" from-port: " << ntohs(socketAddress_.sin_port)
30 <<
" to-port: " << ntohs(ReceiverSocket::fromAddress_.sin_port) << std::endl;
32 constexpr
size_t MAX_SEND_SIZE = 65500;
33 if(buffer.size() > MAX_SEND_SIZE)
35 __COUT__ <<
"Too large! Error writing buffer from port " << ntohs(TransmitterSocket::socketAddress_.sin_port) <<
": " << std::endl;
40 size_t thisSize = buffer.size();
41 int sendToSize = sendto(socketNumber_, buffer.c_str() + offset, thisSize, 0, (
struct sockaddr*)&(ReceiverSocket::fromAddress_),
sizeof(sockaddr_in));
45 __COUT__ <<
"Error writing buffer from port " << ntohs(TransmitterSocket::socketAddress_.sin_port) <<
": " << strerror(errno) << std::endl;