You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was initially brought up in #1643, but the discussion was focused primarily on HANDLE, and was closed.
Rust's built-in UdpSocket has a Windows-only as_raw_socket method that converts it into a std::os::windows::io::RawSocket, which is an alias for std::os::windows::raw::SOCKET, a u64. WinSock methods like WSAIoctl require an IntoParam<SOCKET> using windows::Win32::Networking::WinSock::SOCKET, which wraps a usize.
Since the as_raw_socket method is Windows-only to begin with, it would be nice if these two types interfaced better or had a consistent representation (perhaps ideally just using std::os::windows::raw::SOCKET).
recatek
changed the title
Inconsistency between SOCKET types makes WinSock interop with Rust's UdpSocket nontrivial.
Inconsistency between SOCKET types makes WinSock interop with Rust's UdpSocket nontrivial
Nov 13, 2023
Rust has a Windows-specific socket primitive defined as such:
#[cfg(target_pointer_width = "32")]#[doc(cfg(all()))]#[stable(feature = "raw_ext", since = "1.1.0")]pubtypeSOCKET = u32;#[cfg(target_pointer_width = "64")]#[doc(cfg(all()))]#[stable(feature = "raw_ext", since = "1.1.0")]pubtypeSOCKET = u64;
I'm curious how this missed becoming a usize. 🤔 Looks like the last message on rust-lang/rust#76253 was promising, maybe worth also trying to restart those std discussions?
The standard library has strong stability guarantees (i.e. we try not to break existing code) and that issue was last active three years ago. I'm doubtful that we can change it now (but it would be good if we could).
Suggestion
This was initially brought up in #1643, but the discussion was focused primarily on HANDLE, and was closed.
Rust's built-in
UdpSocket
has a Windows-only as_raw_socket method that converts it into astd::os::windows::io::RawSocket
, which is an alias forstd::os::windows::raw::SOCKET
, au64
. WinSock methods likeWSAIoctl
require anIntoParam<SOCKET>
usingwindows::Win32::Networking::WinSock::SOCKET
, which wraps ausize
.Since the
as_raw_socket
method is Windows-only to begin with, it would be nice if these two types interfaced better or had a consistent representation (perhaps ideally just usingstd::os::windows::raw::SOCKET
).See also rust-lang/rust#76253
The text was updated successfully, but these errors were encountered: