Changeset 1391 for branches/GNU/src/gcc/libjava/java/net/ServerSocket.java
- Timestamp:
- Apr 27, 2004, 8:39:34 PM (22 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
libjava/java/net/ServerSocket.java (modified) (18 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gcc
- Property svn:ignore
-
old new 26 26 configure.vr 27 27 configure.vrs 28 28 29 Makefile 29 dir.info30 30 lost+found 31 31 update.out
-
- Property svn:ignore
-
branches/GNU/src/gcc/libjava/java/net/ServerSocket.java
-
Property cvs2svn:cvs-rev
changed from
1.1to1.1.1.2
r1390 r1391 39 39 40 40 import java.io.IOException; 41 42 41 43 42 44 /* Written using on-line Java Platform 1.2 API Specification. … … 50 52 * server sockets are ready to communicate with one another utilizing 51 53 * whatever application layer protocol they desire. 52 * <p>54 * 53 55 * As with the <code>Socket</code> class, most instance methods of this class 54 56 * simply redirect their calls to an implementation class. … … 59 61 public class ServerSocket 60 62 { 61 62 // Class Variables63 64 63 /** 65 64 * This is the user defined SocketImplFactory, if one is supplied 66 65 */ 67 66 private static SocketImplFactory factory; 68 69 // Instance Variables70 67 71 68 /** … … 76 73 77 74 /** 78 * Private constructor that simply sets the implementation. 79 */ 80 private ServerSocket() 75 * ServerSocketChannel of this ServerSocket. This channel only exists 76 * when the socket is created by ServerSocketChannel.open(). 77 */ 78 private ServerSocketChannel ch; 79 80 private boolean closed = false; 81 82 /** 83 * Constructor that simply sets the implementation. 84 * 85 * @exception IOException If an error occurs 86 * 87 * @specnote This constructor is public since JDK 1.4 88 */ 89 public ServerSocket() throws IOException 81 90 { 82 91 if (factory != null) … … 84 93 else 85 94 impl = new PlainSocketImpl(); 95 96 86 97 } 87 98 … … 94 105 * 95 106 * @exception IOException If an error occurs 107 108 96 109 */ 97 110 public ServerSocket (int port) 98 throws java.io.IOException111 throws IOException 99 112 { 100 113 this(port, 50); … … 111 124 * 112 125 * @exception IOException If an error occurs 126 127 113 128 */ 114 129 public ServerSocket (int port, int backlog) 115 throws java.io.IOException130 throws IOException 116 131 { 117 132 this(port, backlog, null); … … 130 145 * 131 146 * @exception IOException If an error occurs 147 148 149 150 132 151 */ 133 152 public ServerSocket (int port, int backlog, InetAddress bindAddr) 134 throws java.io.IOException153 throws IOException 135 154 { 136 155 this(); 156 137 157 if (impl == null) 138 158 throw new IOException("Cannot initialize Socket implementation"); … … 151 171 152 172 /** 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 153 225 * This method returns the local address to which this socket is bound 154 226 * … … 157 229 public InetAddress getInetAddress() 158 230 { 159 return impl.getInetAddress(); 231 try 232 { 233 return (InetAddress) impl.getOption (SocketOptions.SO_BINDADDR); 234 } 235 catch (SocketException e) 236 { 237 return null; 238 } 160 239 } 161 240 … … 168 247 { 169 248 return impl.getLocalPort(); 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 170 264 } 171 265 … … 176 270 * 177 271 * @exception IOException If an error occurs 178 */ 179 public Socket accept () throws IOException 180 { 272 * @exception SecurityException If a security manager exists and its 273 * checkListen method doesn't allow the operation 274 * @exception IllegalBlockingModeException If this socket has an associated 275 * channel, and the channel is in non-blocking mode 276 * @exception SocketTimeoutException If a timeout was previously set with 277 * setSoTimeout and the timeout has been reached 278 */ 279 public Socket accept () throws IOException 280 { 281 if (impl == null) 282 throw new IOException ("Cannot initialize Socket implementation"); 283 284 SecurityManager sm = System.getSecurityManager (); 285 if (sm != null) 286 sm.checkListen (impl.getLocalPort ()); 287 181 288 Socket s = new Socket(); 182 289 implAccept (s); … … 193 300 * 194 301 * @exception IOException If an error occurs 195 */ 196 protected final void implAccept (Socket s) throws IOException 197 { 302 * @exception IllegalBlockingModeException If this socket has an associated 303 * channel, and the channel is in non-blocking mode 304 * 305 * @since 1.1 306 */ 307 protected final void implAccept (Socket s) 308 throws IOException 309 { 310 if (ch != null && !ch.isBlocking()) 311 throw new IllegalBlockingModeException(); 312 198 313 impl.accept(s.impl); 199 314 } … … 206 321 public void close () throws IOException 207 322 { 208 impl.close(); 323 if (impl != null) 324 impl.close (); 325 326 if (ch != null) 327 ch.close (); 328 329 closed = true; 330 } 331 332 /** 333 * Returns the unique ServerSocketChannel object 334 * associated with this socket, if any. 335 * 336 * The socket only has a ServerSocketChannel if its created 337 * by ServerSocketChannel.open. 338 * 339 * @since 1.4 340 */ 341 public ServerSocketChannel getChannel() 342 { 343 return ch; 344 } 345 346 /** 347 * Returns true then the socket is bound, otherwise false 348 * 349 * @since 1.4 350 */ 351 public boolean isBound() 352 { 353 try 354 { 355 Object bindaddr = impl.getOption (SocketOptions.SO_BINDADDR); 356 } 357 catch (SocketException e) 358 { 359 return false; 360 } 361 362 return true; 363 } 364 365 /** 366 * Returns true if the socket is closed, otherwise false 367 * 368 * @since 1.4 369 */ 370 public boolean isClosed() 371 { 372 return closed; 209 373 } 210 374 … … 217 381 * @param timeout The new SO_TIMEOUT value 218 382 * 219 * @exception IOException If an error occurs 383 * @exception SocketException If an error occurs 384 * 385 * @since 1.1 220 386 */ 221 387 public void setSoTimeout (int timeout) throws SocketException … … 236 402 * 237 403 * @exception IOException If an error occurs 404 405 238 406 */ 239 407 public int getSoTimeout () throws IOException … … 248 416 249 417 /** 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 250 504 * Returns the value of this socket as a <code>String</code>. 251 505 * … … 254 508 public String toString () 255 509 { 256 return "ServerSocket " + impl.toString();510 return "ServerSocket" + impl.toString(); 257 511 } 258 512 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
