mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[wpinet] Wrap a number of newer libuv features (#4260)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user