rust-lang / socket2

Advanced configuration options for sockets.
https://docs.rs/socket2
Apache License 2.0
683 stars 227 forks source link

socket error #498

Closed rosejober closed 8 months ago

rosejober commented 8 months ago

Under Windows 7 system, if the system does not have the sp1 patch installed, specifying WSA_FLAG_NO_HANDLE_INHERIT when creating a socket will return a 10022 error. You need to change the new in socket.rs.

pub fn new(domain: Domain, ty: Type, protocol: Option) -> io::Result { if cfg!(target_os = "windows") { let socket = Socket::new_raw(domain, ty, protocol)?; socket._set_no_inherit(true)?; set_common_flags(socket) }else{ let ty = set_common_type(ty); Socket::new_raw(domain, ty, protocol).and_then(set_common_flags) } }

Thomasdezeeuw commented 8 months ago

I'm not going to support old Windows systems with 0 updates installed. Sorry, but it's just not worth the effort. Please update to sp1, or any Windows version that is supported by Microsoft.