Skip to content

Commit 109fb6a

Browse files
BerrysoftThomasdezeeuw
authored andcommitted
Fix protocol if "all" is not enabled.
1 parent 39050f6 commit 109fb6a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/sys/windows.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ use windows_sys::Win32::Foundation::{SetHandleInformation, HANDLE, HANDLE_FLAG_I
2323
use windows_sys::Win32::Networking::WinSock::{
2424
self, tcp_keepalive, FIONBIO, IN6_ADDR, IN6_ADDR_0, INVALID_SOCKET, IN_ADDR, IN_ADDR_0,
2525
POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, SD_BOTH, SD_RECEIVE, SD_SEND, SIO_KEEPALIVE_VALS,
26-
SOCKET_ERROR, SO_PROTOCOL_INFOW, WSABUF, WSAEMSGSIZE, WSAESHUTDOWN, WSAPOLLFD,
27-
WSAPROTOCOL_INFOW, WSA_FLAG_NO_HANDLE_INHERIT, WSA_FLAG_OVERLAPPED,
26+
SOCKET_ERROR, WSABUF, WSAEMSGSIZE, WSAESHUTDOWN, WSAPOLLFD, WSAPROTOCOL_INFOW,
27+
WSA_FLAG_NO_HANDLE_INHERIT, WSA_FLAG_OVERLAPPED,
2828
};
2929
use windows_sys::Win32::System::Threading::INFINITE;
3030

31-
use crate::{MsgHdr, Protocol, RecvFlags, SockAddr, TcpKeepalive, Type};
31+
use crate::{MsgHdr, RecvFlags, SockAddr, TcpKeepalive, Type};
3232

3333
#[allow(non_camel_case_types)]
3434
pub(crate) type c_int = std::os::raw::c_int;
@@ -924,13 +924,15 @@ impl crate::Socket {
924924
/// Returns the [`Protocol`] of this socket by checking the `SO_PROTOCOL_INFOW`
925925
/// option on this socket.
926926
#[cfg(feature = "all")]
927-
pub fn protocol(&self) -> io::Result<Option<Protocol>> {
927+
pub fn protocol(&self) -> io::Result<Option<crate::Protocol>> {
928+
use windows_sys::Win32::Networking::WinSock::SO_PROTOCOL_INFOW;
929+
928930
let info = unsafe {
929931
getsockopt::<WSAPROTOCOL_INFOW>(self.as_raw(), SOL_SOCKET, SO_PROTOCOL_INFOW)?
930932
};
931933
match info.iProtocol {
932934
0 => Ok(None),
933-
p => Ok(Some(Protocol::from(p))),
935+
p => Ok(Some(crate::Protocol::from(p))),
934936
}
935937
}
936938
}

0 commit comments

Comments
 (0)