|
// Detect read shutdown. A normal zero-length `recv` does block, so |
|
// use deliberately invalid pointer, as we get different error codes in |
|
// the case of a shut-down stream. |
|
let read_result = unsafe { recv(socket, usize::MAX as *mut _, 1, MSG_PEEK) }; |
|
if read_result == SOCKET_ERROR { |
|
let err = io::Error::last_os_error(); |
|
match err.raw_os_error() { |
|
Some(WSAEFAULT) => (), |
|
Some(WSAESHUTDOWN) => read = false, |
|
_ => return Err(err), |
|
} |
|
} |
https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv doesn't say anything about this, this seems sketchy.
system-interface/src/io/is_read_write.rs
Lines 141 to 152 in 8ee8c82
https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv doesn't say anything about this, this seems sketchy.