Skip to content

Commit

Permalink
remove unused and untested udp sendasync method
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky committed Jul 31, 2023
1 parent 50699d8 commit 27b156d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
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

0 comments on commit 27b156d

Please sign in to comment.