jdk/src/share/classes/java/net/Socket.java
changeset 25522 10d789df41bb
parent 24865 09b1d992ca72
equal deleted inserted replaced
25521:80551dd1d902 25522:10d789df41bb
  1022             if (linger < 0) {
  1022             if (linger < 0) {
  1023                 throw new IllegalArgumentException("invalid value for SO_LINGER");
  1023                 throw new IllegalArgumentException("invalid value for SO_LINGER");
  1024             }
  1024             }
  1025             if (linger > 65535)
  1025             if (linger > 65535)
  1026                 linger = 65535;
  1026                 linger = 65535;
  1027             getImpl().setOption(SocketOptions.SO_LINGER, new Integer(linger));
  1027             getImpl().setOption(SocketOptions.SO_LINGER, linger);
  1028         }
  1028         }
  1029     }
  1029     }
  1030 
  1030 
  1031     /**
  1031     /**
  1032      * Returns setting for {@link SocketOptions#SO_LINGER SO_LINGER}.
  1032      * Returns setting for {@link SocketOptions#SO_LINGER SO_LINGER}.
  1138         if (isClosed())
  1138         if (isClosed())
  1139             throw new SocketException("Socket is closed");
  1139             throw new SocketException("Socket is closed");
  1140         if (timeout < 0)
  1140         if (timeout < 0)
  1141           throw new IllegalArgumentException("timeout can't be negative");
  1141           throw new IllegalArgumentException("timeout can't be negative");
  1142 
  1142 
  1143         getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
  1143         getImpl().setOption(SocketOptions.SO_TIMEOUT, timeout);
  1144     }
  1144     }
  1145 
  1145 
  1146     /**
  1146     /**
  1147      * Returns setting for {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT}.
  1147      * Returns setting for {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT}.
  1148      * 0 returns implies that the option is disabled (i.e., timeout of infinity).
  1148      * 0 returns implies that the option is disabled (i.e., timeout of infinity).
  1194         if (!(size > 0)) {
  1194         if (!(size > 0)) {
  1195             throw new IllegalArgumentException("negative send size");
  1195             throw new IllegalArgumentException("negative send size");
  1196         }
  1196         }
  1197         if (isClosed())
  1197         if (isClosed())
  1198             throw new SocketException("Socket is closed");
  1198             throw new SocketException("Socket is closed");
  1199         getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size));
  1199         getImpl().setOption(SocketOptions.SO_SNDBUF, size);
  1200     }
  1200     }
  1201 
  1201 
  1202     /**
  1202     /**
  1203      * Get value of the {@link SocketOptions#SO_SNDBUF SO_SNDBUF} option
  1203      * Get value of the {@link SocketOptions#SO_SNDBUF SO_SNDBUF} option
  1204      * for this {@code Socket}, that is the buffer size used by the platform
  1204      * for this {@code Socket}, that is the buffer size used by the platform
  1268         if (size <= 0) {
  1268         if (size <= 0) {
  1269             throw new IllegalArgumentException("invalid receive size");
  1269             throw new IllegalArgumentException("invalid receive size");
  1270         }
  1270         }
  1271         if (isClosed())
  1271         if (isClosed())
  1272             throw new SocketException("Socket is closed");
  1272             throw new SocketException("Socket is closed");
  1273         getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size));
  1273         getImpl().setOption(SocketOptions.SO_RCVBUF, size);
  1274     }
  1274     }
  1275 
  1275 
  1276     /**
  1276     /**
  1277      * Gets the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option
  1277      * Gets the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option
  1278      * for this {@code Socket}, that is the buffer size used by the platform
  1278      * for this {@code Socket}, that is the buffer size used by the platform
  1378         if (tc < 0 || tc > 255)
  1378         if (tc < 0 || tc > 255)
  1379             throw new IllegalArgumentException("tc is not in range 0 -- 255");
  1379             throw new IllegalArgumentException("tc is not in range 0 -- 255");
  1380 
  1380 
  1381         if (isClosed())
  1381         if (isClosed())
  1382             throw new SocketException("Socket is closed");
  1382             throw new SocketException("Socket is closed");
  1383         getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc));
  1383         getImpl().setOption(SocketOptions.IP_TOS, tc);
  1384     }
  1384     }
  1385 
  1385 
  1386     /**
  1386     /**
  1387      * Gets traffic class or type-of-service in the IP header
  1387      * Gets traffic class or type-of-service in the IP header
  1388      * for packets sent from this Socket
  1388      * for packets sent from this Socket