@Override public boolean isClosed() { return !channel.isOpen(); }
@Override public synchronized void setReceiveBufferSize(int size) throws SocketException { if (size <= 0) { throw new IllegalArgumentException("Receive buffer size must be positive: " + size); } if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } // just ignore }
@Override public void setSendBufferSize(int size) throws SocketException { if (size <= 0) { throw new IllegalArgumentException("Send buffer size must be positive: " + size); } if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } // just ignore }
@Override public synchronized int getReceiveBufferSize() throws SocketException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } throw new UnsupportedOperationException("Getting the receive buffer size is not supported"); }
@Override public synchronized int getSendBufferSize() throws SocketException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } throw new UnsupportedOperationException("Getting the send buffer size is not supported"); }
@Override public InputStream getInputStream() throws IOException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } if (!channel.isConnected()) { throw new SocketException("Socket is not connected"); } if (inputShutdown) { throw new SocketException("Socket input is shutdown"); } return new FilterInputStream(Channels.newInputStream(channel)) { @Override public void close() throws IOException { shutdownInput(); } }; }
@Override public OutputStream getOutputStream() throws IOException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } if (!channel.isConnected()) { throw new SocketException("Socket is not connected"); } if (outputShutdown) { throw new SocketException("Socket output is shutdown"); } return new FilterOutputStream(Channels.newOutputStream(channel)) { @Override public void write(byte[] b, int off, int len) throws IOException { out.write(b, off, len); } @Override public void close() throws IOException { shutdownOutput(); } }; }
@Override public boolean isClosed() { return !channel.isOpen(); }
@Override public void setSendBufferSize(int size) throws SocketException { if (size <= 0) { throw new IllegalArgumentException("Send buffer size must be positive: " + size); } if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } // just ignore }
@Override public synchronized int getSendBufferSize() throws SocketException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } throw new UnsupportedOperationException("Getting the send buffer size is not supported"); }
@Override public synchronized void setReceiveBufferSize(int size) throws SocketException { if (size <= 0) { throw new IllegalArgumentException("Receive buffer size must be positive: " + size); } if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } // just ignore }
@Override public synchronized int getReceiveBufferSize() throws SocketException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } throw new UnsupportedOperationException("Getting the receive buffer size is not supported"); }
@Override public InputStream getInputStream() throws IOException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } if (!channel.isConnected()) { throw new SocketException("Socket is not connected"); } if (inputShutdown) { throw new SocketException("Socket input is shutdown"); } return new FilterInputStream(Channels.newInputStream(channel)) { @Override public void close() throws IOException { shutdownInput(); } }; }
@Override public OutputStream getOutputStream() throws IOException { if (!channel.isOpen()) { throw new SocketException("Socket is closed"); } if (!channel.isConnected()) { throw new SocketException("Socket is not connected"); } if (outputShutdown) { throw new SocketException("Socket output is shutdown"); } return new FilterOutputStream(Channels.newOutputStream(channel)) { @Override public void write(byte[] b, int off, int len) throws IOException { out.write(b, off, len); } @Override public void close() throws IOException { shutdownOutput(); } }; }