public void write(int b) throws IOException { /* * If we need to, we can optimize this allocation. * probably no need to optimize or encourage single byte writes. */ final byte[] buf = new byte[1]; buf[0] = (byte) b; write(buf, 0, 1); }
/** * Util method to build socket addr from either: * <host>:<post> * <fs>://<host>:<port>/<path> */ public static InetSocketAddress createSocketAddr(String target) { return createSocketAddr(target, -1); }
/** * waits for the underlying channel to be ready for writing. * The timeout specified for this stream applies to this wait. * * @throws SocketTimeoutException * if select on the channel times out. * @throws IOException * if any other I/O error occurs. */ public void waitForWritable() throws IOException { writer.waitForIO(SelectionKey.OP_WRITE); }
/** * Create a new input stream with the given timeout. If the timeout * is zero, it will be treated as infinite timeout. The socket's * channel will be configured to be non-blocking. * * @param channel * Channel for reading, should also be a {@link SelectableChannel}. * The channel will be configured to be non-blocking. * @param timeout * timeout in milliseconds. must not be negative. * @throws IOException */ public SocketInputStream(ReadableByteChannel channel, long timeout) throws IOException { SocketIOWithTimeout.checkChannelValidity(channel); reader = new Reader(channel, timeout); }
/** * Create a new ouput stream with the given timeout. If the timeout * is zero, it will be treated as infinite timeout. The socket's * channel will be configured to be non-blocking. * * @param channel * Channel for writing, should also be a {@link SelectableChannel}. * The channel will be configured to be non-blocking. * @param timeout * timeout in milliseconds. must not be negative. * @throws IOException */ public SocketOutputStream(WritableByteChannel channel, long timeout) throws IOException { SocketIOWithTimeout.checkChannelValidity(channel); writer = new Writer(channel, timeout); }
/** * Construct an IPC client with the default SocketFactory * * @param valueClass * @param conf */ public Client() { this(NetUtils.getDefaultSocketFactory()); }
/** * waits for the underlying channel to be ready for reading. * The timeout specified for this stream applies to this wait. * * @throws SocketTimeoutException * if select on the channel times out. * @throws IOException * if any other I/O error occurs. */ public void waitForReadable() throws IOException { reader.waitForIO(SelectionKey.OP_READ); } }
public int read(ByteBuffer dst) throws IOException { return reader.doIO(dst, SelectionKey.OP_READ); }
public boolean isOpen() { return writer.isOpen(); }
public boolean isOpen() { return reader.isOpen(); }
public int write(ByteBuffer src) throws IOException { return writer.doIO(src, SelectionKey.OP_WRITE); }
/** * Create a new input stream with the given timeout. If the timeout * is zero, it will be treated as infinite timeout. The socket's * channel will be configured to be non-blocking. * * @param channel * Channel for reading, should also be a {@link SelectableChannel}. * The channel will be configured to be non-blocking. * @param timeout * timeout in milliseconds. must not be negative. * @throws IOException */ public SocketInputStream(ReadableByteChannel channel, long timeout) throws IOException { SocketIOWithTimeout.checkChannelValidity(channel); reader = new Reader(channel, timeout); }
/** * Create a new ouput stream with the given timeout. If the timeout * is zero, it will be treated as infinite timeout. The socket's * channel will be configured to be non-blocking. * * @param channel * Channel for writing, should also be a {@link SelectableChannel}. * The channel will be configured to be non-blocking. * @param timeout * timeout in milliseconds. must not be negative. * @throws IOException */ public SocketOutputStream(WritableByteChannel channel, long timeout) throws IOException { SocketIOWithTimeout.checkChannelValidity(channel); writer = new Writer(channel, timeout); }
/** * Construct an IPC client with the default SocketFactory * * @param valueClass * @param conf */ public Client() { this(NetUtils.getDefaultSocketFactory()); }
public void write(int b) throws IOException { /* * If we need to, we can optimize this allocation. * probably no need to optimize or encourage single byte writes. */ final byte[] buf = new byte[1]; buf[0] = (byte) b; write(buf, 0, 1); }
/** * Util method to build socket addr from either: * <host>:<post> * <fs>://<host>:<port>/<path> */ public static InetSocketAddress createSocketAddr(String target) { return createSocketAddr(target, -1); }
/** * waits for the underlying channel to be ready for writing. * The timeout specified for this stream applies to this wait. * * @throws SocketTimeoutException * if select on the channel times out. * @throws IOException * if any other I/O error occurs. */ public void waitForWritable() throws IOException { writer.waitForIO(SelectionKey.OP_WRITE); }
/** * waits for the underlying channel to be ready for reading. * The timeout specified for this stream applies to this wait. * * @throws SocketTimeoutException * if select on the channel times out. * @throws IOException * if any other I/O error occurs. */ public void waitForReadable() throws IOException { reader.waitForIO(SelectionKey.OP_READ); } }
public static SocketFactory getSocketFactory() { return getDefaultSocketFactory(); }
public static SocketFactory getSocketFactory() { return getDefaultSocketFactory(); }