477 478 void setInputStream(SocketInputStream in) { 479 socketInputStream = in; 480 } 481 482 /** 483 * Gets an OutputStream for this socket. 484 */ 485 protected synchronized OutputStream getOutputStream() throws IOException { 486 synchronized (fdLock) { 487 if (isClosedOrPending()) 488 throw new IOException("Socket Closed"); 489 if (shut_wr) 490 throw new IOException("Socket output is shutdown"); 491 if (socketOutputStream == null) 492 socketOutputStream = new SocketOutputStream(this); 493 } 494 return socketOutputStream; 495 } 496 497 void setFileDescriptor(FileDescriptor fd) { 498 this.fd = fd; 499 } 500 501 void setAddress(InetAddress address) { 502 this.address = address; 503 } 504 505 void setPort(int port) { 506 this.port = port; 507 } 508 509 void setLocalPort(int localport) { 510 this.localport = localport; 511 } 512 513 /** 514 * Returns the number of bytes that can be read without blocking. 515 */ 516 protected synchronized int available() throws IOException { 517 if (isClosedOrPending()) { 518 throw new IOException("Stream closed."); 519 } 520 521 /* 522 * If connection has been reset or shut down for input, then return 0 523 * to indicate there are no buffered bytes. 524 */ | 477 478 void setInputStream(SocketInputStream in) { 479 socketInputStream = in; 480 } 481 482 /** 483 * Gets an OutputStream for this socket. 484 */ 485 protected synchronized OutputStream getOutputStream() throws IOException { 486 synchronized (fdLock) { 487 if (isClosedOrPending()) 488 throw new IOException("Socket Closed"); 489 if (shut_wr) 490 throw new IOException("Socket output is shutdown"); 491 if (socketOutputStream == null) 492 socketOutputStream = new SocketOutputStream(this); 493 } 494 return socketOutputStream; 495 } 496 497 void setPort(int port) { 498 this.port = port; 499 } 500 501 void setLocalPort(int localport) { 502 this.localport = localport; 503 } 504 505 /** 506 * Returns the number of bytes that can be read without blocking. 507 */ 508 protected synchronized int available() throws IOException { 509 if (isClosedOrPending()) { 510 throw new IOException("Stream closed."); 511 } 512 513 /* 514 * If connection has been reset or shut down for input, then return 0 515 * to indicate there are no buffered bytes. 516 */ |