szaszm commented on code in PR #1412:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1412#discussion_r983674141
##########
libminifi/test/Utils.h:
##########
@@ -111,24 +111,47 @@ bool countLogOccurrencesUntil(const std::string& pattern,
return false;
}
-bool sendMessagesViaTCP(const std::vector<std::string_view>& contents,
uint64_t port) {
+bool sendMessagesViaTCP(const std::vector<std::string_view>& contents, const
asio::ip::tcp::endpoint& remote_endpoint) {
asio::io_context io_context;
asio::ip::tcp::socket socket(io_context);
- asio::ip::tcp::endpoint
remote_endpoint(asio::ip::address::from_string("127.0.0.1"), port);
socket.connect(remote_endpoint);
std::error_code err;
for (auto& content : contents) {
std::string tcp_message(content);
tcp_message += '\n';
asio::write(socket, asio::buffer(tcp_message, tcp_message.size()), err);
+ if (err) {
+ return false;
+ }
}
- if (err) {
- return false;
- }
- socket.close();
return true;
}
+bool sendUdpDatagram(const asio::const_buffer& content, const
asio::ip::udp::endpoint& remote_endpoint) {
Review Comment:
`asio::const_buffer` is cheap to copy, similarly to `gsl::span` and
`std::string_view`. I would pass it by value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]