8280241: (aio) AsynchronousSocketChannel init fails in IPv6 only Windows env
Backport-of: 36fbec78be837fe1defb72f39c6e3f2b5135fddf
This commit is contained in:
parent
5421b29389
commit
83649747f7
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -69,6 +69,10 @@ Java_sun_nio_ch_WindowsAsynchronousServerSocketChannelImpl_initIDs(JNIEnv* env,
|
|||
DWORD dwBytes;
|
||||
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s == INVALID_SOCKET && WSAGetLastError() == WSAEAFNOSUPPORT) {
|
||||
/* IPv4 unavailable... try IPv6 instead */
|
||||
s = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
}
|
||||
if (s == INVALID_SOCKET) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "socket failed");
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -66,6 +66,10 @@ Java_sun_nio_ch_WindowsAsynchronousSocketChannelImpl_initIDs(JNIEnv* env, jclass
|
|||
DWORD dwBytes;
|
||||
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s == INVALID_SOCKET && WSAGetLastError() == WSAEAFNOSUPPORT) {
|
||||
/* IPv4 unavailable... try IPv6 instead */
|
||||
s = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
}
|
||||
if (s == INVALID_SOCKET) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "socket failed");
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue