src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c

Print this page




2222 
2223     /*
2224      * Map the Java level socket option to the platform specific
2225      * level and option name.
2226      */
2227     if (NET_MapSocketOption(opt, &level, &optname)) {
2228         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
2229         return NULL;
2230     }
2231 
2232     if (fd == -1) {
2233         if (NET_MapSocketOptionV6(opt, &level, &optname)) {
2234             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
2235             return NULL;
2236         }
2237         fd = fd1; /* must be IPv6 only */
2238     }
2239 
2240     optlen = sizeof(optval.i);
2241     if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
2242         char errmsg[255];
2243         sprintf(errmsg, "error getting socket option: %s\n", strerror(errno));



2244         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", errmsg);
2245         return NULL;
2246     }
2247 
2248     switch (opt) {
2249         case java_net_SocketOptions_SO_BROADCAST:
2250         case java_net_SocketOptions_SO_REUSEADDR:
2251             return createBoolean(env, optval.i);
2252 
2253         case java_net_SocketOptions_IP_MULTICAST_LOOP:
2254             /* getLoopbackMode() returns true if IP_MULTICAST_LOOP is disabled */
2255             return createBoolean(env, !optval.i);
2256 
2257         case java_net_SocketOptions_SO_SNDBUF:
2258         case java_net_SocketOptions_SO_RCVBUF:
2259         case java_net_SocketOptions_IP_TOS:
2260             return createInteger(env, optval.i);
2261 
2262         default :
2263             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",




2222 
2223     /*
2224      * Map the Java level socket option to the platform specific
2225      * level and option name.
2226      */
2227     if (NET_MapSocketOption(opt, &level, &optname)) {
2228         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
2229         return NULL;
2230     }
2231 
2232     if (fd == -1) {
2233         if (NET_MapSocketOptionV6(opt, &level, &optname)) {
2234             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Invalid option");
2235             return NULL;
2236         }
2237         fd = fd1; /* must be IPv6 only */
2238     }
2239 
2240     optlen = sizeof(optval.i);
2241     if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
2242         char tmpbuf[255];
2243         int size = 0;
2244         char errmsg[255 + 31];
2245         getErrorString(errno, tmpbuf, sizeof(tmpbuf));
2246         sprintf(errmsg, "error getting socket option: %s", tmpbuf);
2247         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", errmsg);
2248         return NULL;
2249     }
2250 
2251     switch (opt) {
2252         case java_net_SocketOptions_SO_BROADCAST:
2253         case java_net_SocketOptions_SO_REUSEADDR:
2254             return createBoolean(env, optval.i);
2255 
2256         case java_net_SocketOptions_IP_MULTICAST_LOOP:
2257             /* getLoopbackMode() returns true if IP_MULTICAST_LOOP is disabled */
2258             return createBoolean(env, !optval.i);
2259 
2260         case java_net_SocketOptions_SO_SNDBUF:
2261         case java_net_SocketOptions_SO_RCVBUF:
2262         case java_net_SocketOptions_IP_TOS:
2263             return createInteger(env, optval.i);
2264 
2265         default :
2266             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",