summaryrefslogtreecommitdiffstats
path: root/contrib/edi
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/edi')
-rw-r--r--contrib/edi/Transport.cpp41
-rw-r--r--contrib/edi/Transport.h2
2 files changed, 21 insertions, 22 deletions
diff --git a/contrib/edi/Transport.cpp b/contrib/edi/Transport.cpp
index 0d5c237..c7bde8f 100644
--- a/contrib/edi/Transport.cpp
+++ b/contrib/edi/Transport.cpp
@@ -87,9 +87,8 @@ Sender::Sender(const configuration_t& conf) :
tcp_dispatchers.emplace(tcp_dest.get(), dispatcher);
}
else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_client_t>(edi_dest)) {
- auto tcp_socket = make_shared<Socket::TCPSocket>();
- tcp_socket->connect(tcp_dest->dest_addr, tcp_dest->dest_port);
- tcp_senders.emplace(tcp_dest.get(), tcp_socket);
+ auto tcp_send_client = make_shared<Socket::TCPSendClient>(tcp_dest->dest_addr, tcp_dest->dest_port);
+ tcp_senders.emplace(tcp_dest.get(), tcp_send_client);
}
else {
throw logic_error("EDI destination not implemented");
@@ -127,8 +126,18 @@ void Sender::write(const TagPacket& tagpacket)
edi_fragments = edi_interleaver.Interleave(edi_fragments);
}
+ if (m_conf.verbose) {
+ fprintf(stderr, "EDI number of PFT fragments %zu\n",
+ edi_fragments.size());
+ }
+
// Send over ethernet
- for (const auto& edi_frag : edi_fragments) {
+ for (auto& edi_frag : edi_fragments) {
+ if (m_conf.dump) {
+ ostream_iterator<uint8_t> debug_iterator(edi_debug_file);
+ copy(edi_frag.begin(), edi_frag.end(), debug_iterator);
+ }
+
for (auto& dest : m_conf.destinations) {
if (const auto& udp_dest = dynamic_pointer_cast<edi::udp_destination_t>(dest)) {
Socket::InetAddress addr;
@@ -140,26 +149,21 @@ void Sender::write(const TagPacket& tagpacket)
tcp_dispatchers.at(tcp_dest.get())->write(edi_frag);
}
else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_client_t>(dest)) {
- tcp_senders.at(tcp_dest.get())->sendall(edi_frag.data(), edi_frag.size());
+ tcp_senders.at(tcp_dest.get())->sendall(move(edi_frag));
}
else {
throw logic_error("EDI destination not implemented");
}
}
-
- if (m_conf.dump) {
- ostream_iterator<uint8_t> debug_iterator(edi_debug_file);
- copy(edi_frag.begin(), edi_frag.end(), debug_iterator);
- }
- }
-
- if (m_conf.verbose) {
- fprintf(stderr, "EDI number of PFT fragments %zu\n",
- edi_fragments.size());
}
}
else {
// Send over ethernet
+ if (m_conf.dump) {
+ ostream_iterator<uint8_t> debug_iterator(edi_debug_file);
+ copy(af_packet.begin(), af_packet.end(), debug_iterator);
+ }
+
for (auto& dest : m_conf.destinations) {
if (const auto& udp_dest = dynamic_pointer_cast<edi::udp_destination_t>(dest)) {
Socket::InetAddress addr;
@@ -171,17 +175,12 @@ void Sender::write(const TagPacket& tagpacket)
tcp_dispatchers.at(tcp_dest.get())->write(af_packet);
}
else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_client_t>(dest)) {
- tcp_senders.at(tcp_dest.get())->sendall(af_packet.data(), af_packet.size());
+ tcp_senders.at(tcp_dest.get())->sendall(move(af_packet));
}
else {
throw logic_error("EDI destination not implemented");
}
}
-
- if (m_conf.dump) {
- ostream_iterator<uint8_t> debug_iterator(edi_debug_file);
- copy(af_packet.begin(), af_packet.end(), debug_iterator);
- }
}
}
diff --git a/contrib/edi/Transport.h b/contrib/edi/Transport.h
index df6fe56..73b2ab6 100644
--- a/contrib/edi/Transport.h
+++ b/contrib/edi/Transport.h
@@ -64,7 +64,7 @@ class Sender {
std::unordered_map<udp_destination_t*, std::shared_ptr<Socket::UDPSocket>> udp_sockets;
std::unordered_map<tcp_server_t*, std::shared_ptr<Socket::TCPDataDispatcher>> tcp_dispatchers;
- std::unordered_map<tcp_client_t*, std::shared_ptr<Socket::TCPSocket>> tcp_senders;
+ std::unordered_map<tcp_client_t*, std::shared_ptr<Socket::TCPSendClient>> tcp_senders;
};
}