Ejemplo n.º 1
0
  /**
   * Comprueba Identificador de cFtp ClusterNet v1.0
   *
   * @param buf Un objeto Buffer con los datos leidos.
   * @return true si se ha recibido el Identificador de cFtp, false en caso contrario
   */
  public static boolean parseIDFTPMulticast(Buffer buf) throws IOException {
    boolean bOK = false;
    try {
      // Leer Magic
      if (buf.getInt(0) != ProtocolcFTP.MAGIC) return bOK;

      if (buf.getInt(4) != ProtocolcFTP.VERSION) return bOK;

      bOK = true;

    } finally {
      return bOK;
    }
  }
Ejemplo n.º 2
0
  /**
   * Recibir Tamaño del Fichero
   *
   * @return lSize Tamaño del Fichero
   */
  private long receiveFileSize() throws IOException {
    long lFileSize = 0;
    try {
      Buffer buf = new Buffer(8);

      // Obtener la longitud del nombre del fichero...
      this.id_socketIn.read(buf.getBuffer());

      lFileSize = buf.getLong(0);

      Log.log("Size: " + lFileSize + newline, "");
    } finally {
      return lFileSize;
    }
  }
Ejemplo n.º 3
0
  /**
   * Recibir Nombre del Fichero
   *
   * @param buf Un objeto Buffer con los datos.
   * @return sFileName Nombre del Fichero. null Si hay un error
   */
  public static String parseFileName(Buffer buf) {
    String sFileName = null;

    try {
      int iLong = 0;
      byte[] bytes = null;

      // Obtener la longitud del nombre del fichero...
      iLong = (int) buf.getInt(16);
      bytes = buf.getBytes(20, iLong);

      // Obtener el nombre del fichero...
      sFileName = new String(bytes);

      // this.getFTP().insertStringJTextPane(" ","icono_entrada");
      // this.getFTP().insertStringJTextPane("Recibiendo fichero: "+sFileName+newline,"entrada");
    } catch (ClusterNetInvalidParameterException e) {;
    } finally {
      return sFileName;
    }
  }
Ejemplo n.º 4
0
  /**
   * Recibir Identificador de cFtp ClusterNet v1.0
   *
   * @return true si se ha recibido el Identificador de cFtp, false en caso contrario
   */
  private boolean receiveIDFTPMulticast() throws IOException {
    boolean bOK = false;
    try {
      Buffer buf = new Buffer(5);

      // Leer Datos...
      this.id_socketIn.read(buf.getBuffer());

      // Comprobar MAGIC
      if (buf.getInt(0) != 0x6DED757B) return bOK;

      // Comprobar VERSION
      if (buf.getByte(4) != 0x01) return bOK;

      bOK = true;

      Log.log("Iniciando la recepción cFtp...", "");

    } finally {
      return bOK;
    }
  }
Ejemplo n.º 5
0
  /**
   * Comprobar Tamaño del Fichero
   *
   * @param buf Un objeto Buffer con los datos.
   * @return lSize Tamaño del Fichero. 0 si hay un error
   */
  public static long parseFileSize(Buffer buf) throws IOException {
    long lFileSize = 0;
    try {
      // Obtener la longitud  del fichero...
      lFileSize = buf.getLong(8);

      // this.getFTP().insertStringJTextPane(" ","icono_entrada");
      // this.getFTP().insertStringJTextPane("Tamaño: "+lFileSize+newline,"entrada");

    } catch (ClusterNetInvalidParameterException e) {;
    } finally {
      return lFileSize;
    }
  }
Ejemplo n.º 6
0
  /**
   * Recibir Nombre del Fichero
   *
   * @return sFileName Nombre del Fichero
   */
  private String receiveFileName() throws IOException {
    String sFileName = null;
    byte[] bytes = null;
    try {
      Buffer buf = new Buffer(2);

      int iLong = 0;

      // Obtener la longitud del nombre del fichero...
      this.id_socketIn.read(buf.getBuffer());

      iLong = (int) buf.getShort(0);
      if (iLong > 0) bytes = new byte[iLong];
      this.id_socketIn.read(bytes);

      // Obtener el nombre del fichero...
      sFileName = new String(bytes);

      Log.log(
          "Receiving file: " + sFileName + " from sender: " + this.id_socketIn.getID_Socket(), "");
    } finally {
      return sFileName;
    }
  }