src/solaris/native/java/net/PlainSocketImpl.c

Print this page
rev 8725 : 8024854: Basic changes and files to build the class library on AIX
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan


 946                         optval.ling.l_onoff = 0;
 947                         optval.ling.l_linger = 0;
 948                     }
 949                     optlen = sizeof(optval.ling);
 950                 } else {
 951                     optval.i = (*env)->GetIntField(env, value, fid);
 952                     optlen = sizeof(optval.i);
 953                 }
 954 
 955                 break;
 956             }
 957 
 958         /* Boolean -> int */
 959         default :
 960             optval.i = (on ? 1 : 0);
 961             optlen = sizeof(optval.i);
 962 
 963     }
 964 
 965     if (NET_SetSockOpt(fd, level, optname, (const void *)&optval, optlen) < 0) {
 966 #ifdef __solaris__
 967         if (errno == EINVAL) {
 968             // On Solaris setsockopt will set errno to EINVAL if the socket
 969             // is closed. The default error message is then confusing
 970             char fullMsg[128];
 971             jio_snprintf(fullMsg, sizeof(fullMsg), "Invalid option or socket reset by remote peer");
 972             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", fullMsg);
 973             return;
 974         }
 975 #endif /* __solaris__ */
 976         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 977                                       "Error setting socket option");
 978     }
 979 }
 980 
 981 /*
 982  * Class:     java_net_PlainSocketImpl
 983  * Method:    socketGetOption
 984  * Signature: (I)I
 985  */
 986 JNIEXPORT jint JNICALL




 946                         optval.ling.l_onoff = 0;
 947                         optval.ling.l_linger = 0;
 948                     }
 949                     optlen = sizeof(optval.ling);
 950                 } else {
 951                     optval.i = (*env)->GetIntField(env, value, fid);
 952                     optlen = sizeof(optval.i);
 953                 }
 954 
 955                 break;
 956             }
 957 
 958         /* Boolean -> int */
 959         default :
 960             optval.i = (on ? 1 : 0);
 961             optlen = sizeof(optval.i);
 962 
 963     }
 964 
 965     if (NET_SetSockOpt(fd, level, optname, (const void *)&optval, optlen) < 0) {
 966 #if defined(__solaris__) || defined(_AIX)
 967         if (errno == EINVAL) {
 968             // On Solaris setsockopt will set errno to EINVAL if the socket
 969             // is closed. The default error message is then confusing
 970             char fullMsg[128];
 971             jio_snprintf(fullMsg, sizeof(fullMsg), "Invalid option or socket reset by remote peer");
 972             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", fullMsg);
 973             return;
 974         }
 975 #endif /* __solaris__ */
 976         NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 977                                       "Error setting socket option");
 978     }
 979 }
 980 
 981 /*
 982  * Class:     java_net_PlainSocketImpl
 983  * Method:    socketGetOption
 984  * Signature: (I)I
 985  */
 986 JNIEXPORT jint JNICALL