Commit d56c07f5 authored by Joseph Noir's avatar Joseph Noir

Use sendto as the socket is no longer connected

parent 0696b6aa
...@@ -1196,13 +1196,16 @@ bool try_accept(native_socket& result, native_socket fd) { ...@@ -1196,13 +1196,16 @@ bool try_accept(native_socket& result, native_socket fd) {
return true; return true;
} }
bool send_datagram(size_t& result, native_socket fd, void* buf, size_t len) { bool send_datagram(size_t& result, native_socket fd, void* buf, size_t buf_len,
sockaddr_storage& sa, size_t sa_len) {
CAF_LOG_TRACE(CAF_ARG(fd) << CAF_ARG(len)); CAF_LOG_TRACE(CAF_ARG(fd) << CAF_ARG(len));
// TODO: Send datgrams! (requires acceess to sockaddr) auto sres = ::sendto(fd, reinterpret_cast<socket_send_ptr>(buf), buf_len,
// ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, no_sigpipe_flag, reinterpret_cast<sockaddr*>(&sa),
// const struct sockaddr *dest_addr, socklen_t addrlen); sa_len);
auto sres = ::send(fd, reinterpret_cast<socket_send_ptr>(buf), len, /*
auto sres = ::send(fd, reinterpret_cast<socket_send_ptr>(buf), buf_len,
no_sigpipe_flag); no_sigpipe_flag);
*/
if (is_error(sres, true)) if (is_error(sres, true))
return false; return false;
result = (sres > 0) ? static_cast<size_t>(sres) : 0; result = (sres > 0) ? static_cast<size_t>(sres) : 0;
...@@ -1610,7 +1613,8 @@ void dgram_communicator::handle_event(operation op) { ...@@ -1610,7 +1613,8 @@ void dgram_communicator::handle_event(operation op) {
} }
case operation::write: { case operation::write: {
size_t wb; // written bytes size_t wb; // written bytes
if (!send_datagram(wb, fd(), wr_buf_.data(), wr_buf_.size())) { if (!send_datagram(wb, fd(), wr_buf_.data(), wr_buf_.size(),
sockaddr_, sockaddr_len_)) {
writer_->io_failure(&backend(), operation::write); writer_->io_failure(&backend(), operation::write);
backend().del(operation::write, fd(), this); backend().del(operation::write, fd(), this);
} else if (wb > 0) { } else if (wb > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment