Code example for Socket

Methods: getChannel

   * @param timeout timeout timeout in milliseconds. must not be negative. 
   * @throws IOException 
  public SocketOutputStream(Socket socket, long timeout) 
                                         throws IOException { 
    this(socket.getChannel(), timeout);
  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. 
    byte[] buf = new byte[1];
    buf[0] = (byte)b;
    write(buf, 0, 1);
  public void write(byte[] b, int off, int len) throws IOException {
    ByteBuffer buf = ByteBuffer.wrap(b, off, len);
    while (buf.hasRemaining()) {
      try {