mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8221252: (sc) SocketChannel and its socket adaptor need to handle connection reset
Reviewed-by: bpb
This commit is contained in:
parent
cc590f5765
commit
3a4d5db248
13 changed files with 507 additions and 88 deletions
|
@ -310,6 +310,12 @@ public class Net {
|
|||
static final ExtendedSocketOptions extendedOptions =
|
||||
ExtendedSocketOptions.getInstance();
|
||||
|
||||
static void setSocketOption(FileDescriptor fd, SocketOption<?> name, Object value)
|
||||
throws IOException
|
||||
{
|
||||
setSocketOption(fd, Net.UNSPEC, name, value);
|
||||
}
|
||||
|
||||
static void setSocketOption(FileDescriptor fd, ProtocolFamily family,
|
||||
SocketOption<?> name, Object value)
|
||||
throws IOException
|
||||
|
@ -372,8 +378,13 @@ public class Net {
|
|||
setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg, isIPv6);
|
||||
}
|
||||
|
||||
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
|
||||
SocketOption<?> name)
|
||||
static Object getSocketOption(FileDescriptor fd, SocketOption<?> name)
|
||||
throws IOException
|
||||
{
|
||||
return getSocketOption(fd, Net.UNSPEC, name);
|
||||
}
|
||||
|
||||
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, SocketOption<?> name)
|
||||
throws IOException
|
||||
{
|
||||
Class<?> type = name.type();
|
||||
|
@ -426,8 +437,7 @@ public class Net {
|
|||
return socket(UNSPEC, stream);
|
||||
}
|
||||
|
||||
static FileDescriptor socket(ProtocolFamily family, boolean stream)
|
||||
throws IOException {
|
||||
static FileDescriptor socket(ProtocolFamily family, boolean stream) throws IOException {
|
||||
boolean preferIPv6 = isIPv6Available() &&
|
||||
(family != StandardProtocolFamily.INET);
|
||||
return IOUtil.newFD(socket0(preferIPv6, stream, false, fastLoopback));
|
||||
|
@ -525,20 +535,43 @@ public class Net {
|
|||
int level, int opt, int arg, boolean isIPv6)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Polls a file descriptor for events.
|
||||
* @param timeout the timeout to wait; 0 to not wait, -1 to wait indefinitely
|
||||
* @return the polled events or 0 if no events are polled
|
||||
*/
|
||||
static native int poll(FileDescriptor fd, int events, long timeout)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Performs a non-blocking poll of a file descriptor.
|
||||
* @return the polled events or 0 if no events are polled
|
||||
*/
|
||||
static int pollNow(FileDescriptor fd, int events) throws IOException {
|
||||
return poll(fd, events, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Polls a connecting socket to test if the connection has been established.
|
||||
*
|
||||
* @apiNote This method is public to allow it be used by code in jdk.sctp.
|
||||
*
|
||||
* @param timeout the timeout to wait; 0 to not wait, -1 to wait indefinitely
|
||||
* @return 1 if connected, 0 if not connected, or IOS_INTERRUPTED
|
||||
* @return true if connected
|
||||
*/
|
||||
public static native int pollConnect(FileDescriptor fd, long timeout)
|
||||
public static native boolean pollConnect(FileDescriptor fd, long timeout)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Performs a non-blocking poll of a connecting socket to test if the
|
||||
* connection has been established.
|
||||
*
|
||||
* @return true if connected
|
||||
*/
|
||||
static boolean pollConnectNow(FileDescriptor fd) throws IOException {
|
||||
return pollConnect(fd, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of bytes in the socket input buffer.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue