8217461: (ch) Add Net.available to return the number of bytes in the socket input buffer
Langer, Christoph
christoph.langer at sap.com
Tue Jan 22 08:07:02 UTC 2019
Hi Alan,
the change looks good to me.
In src/java.base/unix/native/libnio/ch/Net.c and src/java.base/windows/native/libnio/ch/Net.c you could change the code from
...
int n = NET_SocketAvailable(fdval(env, fdo), &count);
if (n != 0) {
...
to one line
if (NET_SocketAvailable(fdval(env, fdo), &count) != 0) {
as it is done in src/java.base/unix/native/libnet/PlainSocketImpl.c
The variable n is not used except for the returncode check.
By the way, looking at the 2 implementations of Net.c for unix resp. windows, it seems they have quite some code in common. Isn't that something where the shared parts could be merged into one file?
Best regards
Christoph
> -----Original Message-----
> From: nio-dev <nio-dev-bounces at openjdk.java.net> On Behalf Of Alan
> Bateman
> Sent: Montag, 21. Januar 2019 20:10
> To: nio-dev at openjdk.java.net; OpenJDK Network Dev list <net-
> dev at openjdk.java.net>
> Subject: 8217461: (ch) Add Net.available to return the number of bytes in the
> socket input buffer
>
> This is a small change to add a method to sun.nio.ch.Net to get the
> number of bytes in the socket input buffer. The motive for adding this
> to make it possible for the socket adaptors to implement
> InputStream::available and also to support an alternative SocketImpl
> based on NIO. I've used the opportunity to clean up NET_SocketAvailable
> in libnet so that it returns 0 when it succeeds.
>
> The proposed changes are here:
> http://cr.openjdk.java.net/~alanb/8217461/webrev/index.html
>
> -Alan
More information about the net-dev
mailing list