lpr-b:nslookup
no way to compare when less than two revisions
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
— | lpr-b:nslookup [13/11/2007 alle 18:54 (18 anni fa)] (versione attuale) – creata Marco Danelutto | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
+ | <code java> | ||
+ | package nslookup; | ||
+ | import java.io.IOException; | ||
+ | import java.io.ObjectInputStream; | ||
+ | import java.io.ObjectOutputStream; | ||
+ | import java.net.InetAddress; | ||
+ | import java.net.Socket; | ||
+ | import java.net.UnknownHostException; | ||
+ | |||
+ | public class Nslookup { | ||
+ | |||
+ | /** | ||
+ | * @param args | ||
+ | */ | ||
+ | public static void main(String[] args) { | ||
+ | |||
+ | if(args.length == 0) { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } | ||
+ | String serverName = args[0]; | ||
+ | String hostName = args[1]; | ||
+ | boolean cached = Boolean.parseBoolean(args[2]); | ||
+ | | ||
+ | InetAddress sa = null; | ||
+ | try { | ||
+ | System.out.println(" | ||
+ | sa = InetAddress.getByName(serverName); | ||
+ | System.out.println(" | ||
+ | } catch (UnknownHostException e) { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } | ||
+ | Socket s = null; | ||
+ | try { | ||
+ | s = new Socket(sa, | ||
+ | } catch (IOException e) { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } | ||
+ | ObjectOutputStream oos; | ||
+ | try { | ||
+ | oos = new ObjectOutputStream(s.getOutputStream()); | ||
+ | } catch (IOException e) { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } | ||
+ | NameQuery nq = new NameQuery(hostName, | ||
+ | long t0 = System.currentTimeMillis(); | ||
+ | try { | ||
+ | oos.writeObject(nq); | ||
+ | } catch (IOException e) { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } | ||
+ | ObjectInputStream ois = null; | ||
+ | try { | ||
+ | ois = new ObjectInputStream(s.getInputStream()); | ||
+ | } catch (IOException e) { | ||
+ | System.out.println(" | ||
+ | } | ||
+ | QueryAnswer qa = null; | ||
+ | long t1 = 0L; | ||
+ | try { | ||
+ | qa = (QueryAnswer) ois.readObject(); | ||
+ | t1 = System.currentTimeMillis(); | ||
+ | } catch (IOException e) { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } catch (ClassNotFoundException e) { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } | ||
+ | System.out.println(" | ||
+ | System.out.println(" | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ |
lpr-b/nslookup.txt · Ultima modifica: 13/11/2007 alle 18:54 (18 anni fa) da Marco Danelutto