/**
   * Performs standard initializations on a newly created socket.
   *
   * @param sock the socket to prepare
   * @param context the context for the connection
   * @param params the parameters from which to prepare the socket
   * @throws IOException in case of an IO problem
   */
  protected void prepareSocket(Socket sock, HttpContext context, HttpParams params)
      throws IOException {

    // context currently not used, but derived classes may need it
    // @@@ is context allowed to be null?

    sock.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
    sock.setSoTimeout(HttpConnectionParams.getSoTimeout(params));

    int linger = HttpConnectionParams.getLinger(params);
    if (linger >= 0) {
      sock.setSoLinger(linger > 0, linger);
    }
  } // prepareSocket