added correct error code for WSASocketW failure fallback

This commit is contained in:
avikozokin 2019-12-02 20:12:51 +02:00
parent fdc0011561
commit fa8b54901f

View File

@ -100,7 +100,7 @@ pub fn new(addr: &SocketAddr, ty: c_int) -> io::Result<Socket> {
c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT) { c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT) {
c::INVALID_SOCKET => { c::INVALID_SOCKET => {
match c::WSAGetLastError() { match c::WSAGetLastError() {
c::WSAEPROTOTYPE => { c::WSAEPROTOTYPE | c::WSAEINVAL => {
match c::WSASocketW(fam, ty, 0, ptr::null_mut(), 0, match c::WSASocketW(fam, ty, 0, ptr::null_mut(), 0,
c::WSA_FLAG_OVERLAPPED) { c::WSA_FLAG_OVERLAPPED) {
c::INVALID_SOCKET => Err(last_error()), c::INVALID_SOCKET => Err(last_error()),
@ -199,7 +199,7 @@ pub fn duplicate(&self) -> io::Result<Socket> {
c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT) { c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT) {
c::INVALID_SOCKET => { c::INVALID_SOCKET => {
match c::WSAGetLastError() { match c::WSAGetLastError() {
c::WSAEPROTOTYPE => { c::WSAEPROTOTYPE | c::WSAEINVAL => {
match c::WSASocketW(info.iAddressFamily, match c::WSASocketW(info.iAddressFamily,
info.iSocketType, info.iSocketType,
info.iProtocol, info.iProtocol,