src/java.base/unix/native/libnio/ch/Net.c
changeset 53422 6f02e036630e
parent 52073 1c8745e31fa3
child 53445 c96f9aa1f3d8
--- a/src/java.base/unix/native/libnio/ch/Net.c	Thu Jan 03 17:39:39 2019 +0800
+++ b/src/java.base/unix/native/libnio/ch/Net.c	Tue Jan 22 16:39:52 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -684,6 +684,17 @@
 }
 
 JNIEXPORT jint JNICALL
+Java_sun_nio_ch_Net_available(JNIEnv *env, jclass cl, jobject fdo)
+{
+    int count = 0;
+    if (NET_SocketAvailable(fdval(env, fdo), &count) != 0) {
+        handleSocketError(env, errno);
+        return IOS_THROWN;
+    }
+    return (jint) count;
+}
+
+JNIEXPORT jint JNICALL
 Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlong timeout)
 {
     struct pollfd pfd;