[wpinet] Wrap a number of newer libuv features (#4260)

This commit is contained in:
Peter Johnson
2022-05-22 20:18:23 -07:00
committed by GitHub
parent 816aa4e465
commit 013efdde25
7 changed files with 97 additions and 0 deletions

View File

@@ -106,4 +106,14 @@ int Stream::TryWrite(span<const Buffer> bufs) {
return val;
}
int Stream::TryWrite2(span<const Buffer> bufs, Stream& send) {
int val = uv_try_write2(GetRawStream(), bufs.data(), bufs.size(),
send.GetRawStream());
if (val < 0) {
this->ReportError(val);
return 0;
}
return val;
}
} // namespace wpi::uv

View File

@@ -167,4 +167,15 @@ void Tcp::Connect6(std::string_view ip, unsigned int port,
}
}
void Tcp::CloseReset() {
if (!IsClosing()) {
uv_tcp_close_reset(GetRaw(), [](uv_handle_t* handle) {
Tcp& h = *static_cast<Tcp*>(handle->data);
h.closed();
h.Release(); // free ourselves
});
ForceClosed();
}
}
} // namespace wpi::uv

View File

@@ -117,6 +117,17 @@ void Udp::SetMembership(std::string_view multicastAddr,
interfaceAddrBuf.c_str(), membership);
}
void Udp::SetSourceMembership(std::string_view multicastAddr,
std::string_view interfaceAddr,
std::string_view sourceAddr,
uv_membership membership) {
SmallString<128> multicastAddrBuf{multicastAddr};
SmallString<128> interfaceAddrBuf{interfaceAddr};
SmallString<128> sourceAddrBuf{sourceAddr};
Invoke(&uv_udp_set_source_membership, GetRaw(), multicastAddrBuf.c_str(),
interfaceAddrBuf.c_str(), sourceAddrBuf.c_str(), membership);
}
void Udp::SetMulticastInterface(std::string_view interfaceAddr) {
SmallString<128> interfaceAddrBuf{interfaceAddr};
Invoke(&uv_udp_set_multicast_interface, GetRaw(), interfaceAddrBuf.c_str());