Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: remove unused and untested udp sendasync method #1171

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 1 addition & 43 deletions ecal/core/src/io/udp_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,9 @@ namespace eCAL
{
public:
CUDPSenderImpl(const SSenderAttr& attr_);

size_t Send (const void* buf_, size_t len_, const char* ipaddr_ = nullptr);
void SendAsync(const void* buf_, size_t len_, const char* ipaddr_ = nullptr);
size_t Send(const void* buf_, size_t len_, const char* ipaddr_ = nullptr);

protected:
void SendAsync(asio::const_buffer buf_, const char* ipaddr_);
void OnSendAsync(asio::error_code ec_, std::size_t bytes_transferred_, asio::const_buffer buf_, const char* ipaddr_);

bool m_broadcast;
bool m_unicast;
asio::io_context m_iocontext;
Expand Down Expand Up @@ -127,37 +122,6 @@ namespace eCAL
return(sent);
}

void CUDPSenderImpl::SendAsync(const void* buf_, const size_t len_, const char* ipaddr_)
{
SendAsync(asio::buffer(buf_, len_), ipaddr_);
m_iocontext.run();
}

void CUDPSenderImpl::SendAsync(asio::const_buffer buf_, const char* ipaddr_)
{
if ((ipaddr_ != nullptr) && (ipaddr_[0] != '\0')) m_socket.async_send_to(buf_, asio::ip::udp::endpoint(asio::ip::make_address(ipaddr_), m_port), std::bind(&CUDPSenderImpl::OnSendAsync, this, std::placeholders::_1, std::placeholders::_2, buf_, ipaddr_));
else m_socket.async_send_to(buf_, m_endpoint, std::bind(&CUDPSenderImpl::OnSendAsync, this, std::placeholders::_1, std::placeholders::_2, buf_, ipaddr_));
}

void CUDPSenderImpl::OnSendAsync(asio::error_code ec_, std::size_t bytes_transferred_, asio::const_buffer buf_, const char* ipaddr_)
{
if (!ec_)
{
// bytes_transferred_ amount of data was successfully sent
auto bytes_left = buf_ + bytes_transferred_;
if (bytes_left.size() != 0u)
{
// send "rest data" in the next SendAsync operation
SendAsync(bytes_left, ipaddr_);
}
m_iocontext.stop();
}
else
{
std::cout << "CUDPSender::OnSend failed with: \'" << ec_.message() << "\'" << std::endl;
}
}

////////////////////////////////////////////////////////
// udp sender class
////////////////////////////////////////////////////////
Expand All @@ -171,10 +135,4 @@ namespace eCAL
if (!m_socket_impl) return(0);
return(m_socket_impl->Send(buf_, len_, ipaddr_));
}

void CUDPSender::SendAsync(const void* buf_, const size_t len_, const char* ipaddr_)
{
if (!m_socket_impl) return;
m_socket_impl->SendAsync(buf_, len_, ipaddr_);
}
}
4 changes: 1 addition & 3 deletions ecal/core/src/io/udp_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ namespace eCAL
{
public:
CUDPSender(const SSenderAttr& attr_);

size_t Send (const void* buf_, size_t len_, const char* ipaddr_ = nullptr);
void SendAsync(const void* buf_, size_t len_, const char* ipaddr_ = nullptr);
size_t Send(const void* buf_, size_t len_, const char* ipaddr_ = nullptr);

protected:
std::shared_ptr<CUDPSenderImpl> m_socket_impl;
Expand Down
Loading