Exemplo n.º 1
0
 /** List file names */
 public Enumeration nlst(String s) throws IOException {
   InetAddress inetAddress = InetAddress.getLocalHost();
   byte ab[] = inetAddress.getAddress();
   serverSocket_ = new ServerSocket(0, 1);
   StringBuffer sb = new StringBuffer(32);
   sb.append("PORT ");
   for (int i = 0; i < ab.length; i++) {
     sb.append(String.valueOf(ab[i] & 255));
     sb.append(",");
   }
   sb.append(String.valueOf(serverSocket_.getLocalPort() >>> 8 & 255));
   sb.append(",");
   sb.append(String.valueOf(serverSocket_.getLocalPort() & 255));
   if (issueCommand(sb.toString()) != FTP_SUCCESS) {
     serverSocket_.close();
     throw new IOException(getResponseString());
   } else if (issueCommand("NLST " + ((s == null) ? "" : s)) != FTP_SUCCESS) {
     serverSocket_.close();
     throw new IOException(getResponseString());
   }
   dataSocket_ = serverSocket_.accept();
   serverSocket_.close();
   serverSocket_ = null;
   Vector v = readServerResponse_(dataSocket_.getInputStream());
   dataSocket_.close();
   dataSocket_ = null;
   return (v == null) ? null : v.elements();
 }
Exemplo n.º 2
0
 public byte[] getRAddr() {
   try {
     InetAddress addr = InetAddress.getByName(host);
     return addr.getAddress();
   } catch (UnknownHostException e) {
     System.err.println("NCCPConnection::getRAddr Don't know about host: ");
     return null;
   }
 }
Exemplo n.º 3
0
 public static String inaddrString(InetAddress addr) {
   byte[] address = addr.getAddress();
   StringBuffer sb = new StringBuffer();
   for (int i = 3; i >= 0; i--) {
     sb.append(address[i] & 0xFF);
     sb.append(".");
   }
   sb.append(".IN-ADDR.ARPA.");
   return sb.toString();
 }
 /** InetAddress: size = 4 */
 public static void InetAddressToArray(InetAddress inet, byte[] b, int offset) {
   System.arraycopy(inet.getAddress(), 0, b, offset, 4);
 }
  /** {@inheritDoc} */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    U.writeByteArray(out, addr.getAddress());
  }