aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edi/Transport.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-04-21 15:51:31 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-04-21 15:51:31 +0200
commit43d5fa8e85dd013391a8eafc16350cc13b008389 (patch)
tree63b93aefd0428a6e4a3604d73f1ab076a601f3ad /lib/edi/Transport.cpp
parent0aa8e58e6763bda1d20246155e61b7cd54cdfc65 (diff)
downloadODR-SourceCompanion-43d5fa8e85dd013391a8eafc16350cc13b008389.tar.gz
ODR-SourceCompanion-43d5fa8e85dd013391a8eafc16350cc13b008389.tar.bz2
ODR-SourceCompanion-43d5fa8e85dd013391a8eafc16350cc13b008389.zip
Common 33a8362: EDI TCP output: handle disconnects
Diffstat (limited to 'lib/edi/Transport.cpp')
-rw-r--r--lib/edi/Transport.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/edi/Transport.cpp b/lib/edi/Transport.cpp
index 0d5c237..4c91483 100644
--- a/lib/edi/Transport.cpp
+++ b/lib/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(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(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);
- }
}
}