Skip to content

Commit

Permalink
Merge pull request #8 from liloew/master
Browse files Browse the repository at this point in the history
fix: support windows building
  • Loading branch information
leshow authored Feb 7, 2024
2 parents 81f9da7 + 439714e commit 0c81c88
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@

use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket},
os::unix::prelude::{FromRawFd, IntoRawFd},
sync::Arc,
time::Instant,
};

#[cfg(unix)]
use std::os::unix::prelude::{FromRawFd, IntoRawFd};
#[cfg(windows)]
use std::os::windows::prelude::{FromRawSocket, IntoRawSocket};

#[cfg(feature = "script")]
use std::path::PathBuf;

Expand Down Expand Up @@ -107,6 +111,7 @@ fn main() -> Result<()> {
socket
.set_reuse_address(true)
.context("failed to set_reuse_address")?;
#[cfg(unix)]
socket
.set_reuse_port(true)
.context("failed to set_reuse_address")?;
Expand Down Expand Up @@ -147,7 +152,7 @@ fn main() -> Result<()> {
let socket = {
#[cfg(windows)]
unsafe {
UdpSocket::from_raw_socket(socket.into_raw_socket())?
UdpSocket::from_raw_socket(socket.into_raw_socket())
}
#[cfg(unix)]
unsafe {
Expand Down

0 comments on commit 0c81c88

Please sign in to comment.