1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
2545 * Method: join
2546 * Signature: (Ljava/net/InetAddress;)V
2547 */
2548 JNIEXPORT void JNICALL
2549 Java_java_net_TwoStacksPlainDatagramSocketImpl_join(JNIEnv *env, jobject this,
2550 jobject iaObj, jobject niObj)
2551 {
2552 mcast_join_leave (env, this, iaObj, niObj, JNI_TRUE);
2553 }
2554
2555 /*
2556 * Class: java_net_TwoStacksPlainDatagramSocketImpl
2557 * Method: leave
2558 * Signature: (Ljava/net/InetAddress;)V
2559 */
2560 JNIEXPORT void JNICALL
2561 Java_java_net_TwoStacksPlainDatagramSocketImpl_leave(JNIEnv *env, jobject this,
2562 jobject iaObj, jobject niObj)
2563 {
2564 mcast_join_leave (env, this, iaObj, niObj, JNI_FALSE);
2565 }
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
2545 * Method: join
2546 * Signature: (Ljava/net/InetAddress;)V
2547 */
2548 JNIEXPORT void JNICALL
2549 Java_java_net_TwoStacksPlainDatagramSocketImpl_join(JNIEnv *env, jobject this,
2550 jobject iaObj, jobject niObj)
2551 {
2552 mcast_join_leave (env, this, iaObj, niObj, JNI_TRUE);
2553 }
2554
2555 /*
2556 * Class: java_net_TwoStacksPlainDatagramSocketImpl
2557 * Method: leave
2558 * Signature: (Ljava/net/InetAddress;)V
2559 */
2560 JNIEXPORT void JNICALL
2561 Java_java_net_TwoStacksPlainDatagramSocketImpl_leave(JNIEnv *env, jobject this,
2562 jobject iaObj, jobject niObj)
2563 {
2564 mcast_join_leave (env, this, iaObj, niObj, JNI_FALSE);
2565 }
2566
2567 /*
2568 * Class: java_net_TwoStacksPlainDatagramSocketImpl
2569 * Method: dataAvailable
2570 * Signature: ()I
2571 */
2572 JNIEXPORT jint JNICALL Java_java_net_TwoStacksPlainDatagramSocketImpl_dataAvailable
2573 (JNIEnv *env, jobject this) {
2574 SOCKET fd;
2575 SOCKET fd1;
2576 int rv = -1, rv1 = -1;
2577 jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
2578 jobject fd1Obj;
2579
2580 if (!IS_NULL(fdObj)) {
2581 int retval = 0;
2582 fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID);
2583 rv = ioctlsocket(fd, FIONREAD, &retval);
2584 if (retval > 0) {
2585 return retval;
2586 }
2587 }
2588
2589 fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
2590 if (!IS_NULL(fd1Obj)) {
2591 int retval = 0;
2592 fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
2593 rv1 = ioctlsocket(fd1, FIONREAD, &retval);
2594 if (retval > 0) {
2595 return retval;
2596 }
2597 }
2598
2599 if (rv < 0 && rv1 < 0) {
2600 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
2601 "Socket closed");
2602 return -1;
2603 }
2604
2605 return 0;
2606 }
|