mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-07-03 00:17:17 +00:00
add illumos support
This commit is contained in:
parent
16900b9b06
commit
073bae1e73
@ -68,10 +68,11 @@ pub(crate) fn new_socket(addr: std::net::SocketAddr, reuse: bool) -> Result<TcpS
|
|||||||
std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?,
|
std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?,
|
||||||
};
|
};
|
||||||
if reuse {
|
if reuse {
|
||||||
// windows has no reuse_port, but it's reuse_address
|
// windows has no reuse_port, but its reuse_address
|
||||||
// almost equals to unix's reuse_port + reuse_address,
|
// almost equals to unix's reuse_port + reuse_address,
|
||||||
// though may introduce nondeterministic behavior
|
// though may introduce nondeterministic behavior
|
||||||
#[cfg(unix)]
|
// illumos has no support for SO_REUSEPORT
|
||||||
|
#[cfg(all(unix, not(target_os = "illumos")))]
|
||||||
socket.set_reuseport(true).ok();
|
socket.set_reuseport(true).ok();
|
||||||
socket.set_reuseaddr(true).ok();
|
socket.set_reuseaddr(true).ok();
|
||||||
}
|
}
|
||||||
@ -226,6 +227,8 @@ pub async fn listen_any(port: u16) -> ResultType<TcpListener> {
|
|||||||
if let Ok(mut socket) = TcpSocket::new_v6() {
|
if let Ok(mut socket) = TcpSocket::new_v6() {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
|
// illumos has no support for SO_REUSEPORT
|
||||||
|
#[cfg(not(target_os = "illumos"))]
|
||||||
socket.set_reuseport(true).ok();
|
socket.set_reuseport(true).ok();
|
||||||
socket.set_reuseaddr(true).ok();
|
socket.set_reuseaddr(true).ok();
|
||||||
use std::os::unix::io::{FromRawFd, IntoRawFd};
|
use std::os::unix::io::{FromRawFd, IntoRawFd};
|
||||||
|
@ -20,10 +20,11 @@ fn new_socket(addr: SocketAddr, reuse: bool, buf_size: usize) -> Result<Socket,
|
|||||||
SocketAddr::V6(..) => Socket::new(Domain::ipv6(), Type::dgram(), None),
|
SocketAddr::V6(..) => Socket::new(Domain::ipv6(), Type::dgram(), None),
|
||||||
}?;
|
}?;
|
||||||
if reuse {
|
if reuse {
|
||||||
// windows has no reuse_port, but it's reuse_address
|
// windows has no reuse_port, but its reuse_address
|
||||||
// almost equals to unix's reuse_port + reuse_address,
|
// almost equals to unix's reuse_port + reuse_address,
|
||||||
// though may introduce nondeterministic behavior
|
// though may introduce nondeterministic behavior
|
||||||
#[cfg(unix)]
|
// illumos has no support for SO_REUSEPORT
|
||||||
|
#[cfg(all(unix, not(target_os = "illumos")))]
|
||||||
socket.set_reuse_port(true).ok();
|
socket.set_reuse_port(true).ok();
|
||||||
socket.set_reuse_address(true).ok();
|
socket.set_reuse_address(true).ok();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user