Esplora E-book
Categorie
Esplora Audiolibri
Categorie
Esplora Riviste
Categorie
Esplora Documenti
Categorie
Parte X Varie
progettazione di un software e precisamente un applet che permettera un certo numero di funzionalita comunque legate ai concetti di rete. Quando un utente si collega ad un sito e visualizza le pagine presente su questo potrebbe trovarsi dinanzi ad diverse esigenze che lo costringerebbero a ricercare ed a caricare degli altri software. Il software di cui vedremo la progettazione dovrebbe permettere : 1. 2. 3. 4. 5. Invio di messaggi all host senza utilizzare mailer esterni Utilizzo di una sessione FTP per prelevare dei file dal l host Connessione ad hosts selezionandoli da una lista proposta Ricerche su motori di ricerca senza uscire dalla pagina Indicizzazioni di strutture di pagine html alla fine della ricerca di vocaboli o frasi.
Mediante lo sviluppo di queste funzioni verranno viste alcune classi legate ai protocolli e all utilizzo di alcune risorse. Tra le classi utilizzate ci sono la classe sun.net.ftp, la sun.net.smtp Questo primo pezzo di programma e quello che crea il frame principale e, mediante un gestore di layout a schede, permette la navigazione tra le diverse funzionalita del programma. Il gestore di layout a schede e quello in cui lo sfondo rimane sempre invariato e gli oggetti presentati sull interfaccia utente vengono inseriti selezionando la maschera adatta mediante dei tabulatori. L interfaccia compatibile alle versioni 1.0 e 1.1 del JDK messa a confronto con lo stesso gestore di layout di Windows e abbastanza rustica. Prima di vedere il codice vero e proprio diamo un occhiata alla specifica APPLET dentro al file HTML. <applet code="javaCenter.class" align="baseline" width="8" height="19" alt="The appletUtil Applet" name="javaCenter"> <param name="firstpage" value="appletUtil.html"> <param name="mailto" value="flavio@bernardotti.al.it"> <param name="mailhost" value="www.bernardotti.al.it"></applet> Il primo parametro, firstpage, specifica da quale pagina iniziare la ricerca dei vocaboli o delle frasi specificate nella funzione di ricerca dell applet. Gli altri due parametri, mailto e mailhost, specificano rispettivamente l indirizzo a cui inviare le mail e il server da utilizzare per l invio. Vediamo ora la prima parte del programma.
Parte 1 file javaCenter.java
// --------------------------------------------------------------------------------------// import delle classi utilizzate // --------------------------------------------------------------------------------------import import import import import import import import import import import import java.applet.*; java.applet.Applet; java.awt.*; java.awt.image.*; java.awt.event.*; java.lang.reflect.*; java.net.*; java.util.*; java.io.*; sun.net.smtp.*; sun.net.ftp.*; sun.net.*;
// --------------------------------------------------------------------------------------// Gestisce il FRAME principale // --------------------------------------------------------------------------------------class javaCenterFrame extends Frame implements ActionListener, WindowListener
cards = new Panel(); // --------------------------------------------------------------------------------------// Stabilisce che il gestore del layout e a schede // --------------------------------------------------------------------------------------layout = new CardLayout(); cards.setLayout(layout); // --------------------------------------------------------------------------------------// Stabilisce per ogni pannello le funzioni assegnandogli la classe che dovra // essere creata e richiamata a seconda della selezione fatta. // --------------------------------------------------------------------------------------cards.add("Invia mail", new javaCenterSendMail(applet, m_mailhost, m_mailto)); cards.add("Esegui ricerche", new javaCenterSearch(applet)); cards.add("Links", new javaCenterLinks(applet)); cards.add("FTP", new javaCenterFTP(m_ftpserver)); cards.add("Cerca su host", new javaCenterSHost(m_firstpage, applet)); add("Center", cards); setBackground(Color.lightGray); addWindowListener(this); pack(); setSize(500, 360); setVisible(true); } // --------------------------------------------------------------------------------------// Intercetta gli eventi che avvengono sugli oggetti precedentemente registrati // --------------------------------------------------------------------------------------public void actionPerformed(ActionEvent e) { String selected = e.getActionCommand(); if(selected.equals("<<")) { layout.first(cards); return; } if(selected.equals(">>")) { layout.last(cards); return; } if(selected.equals("<")) { layout.previous(cards); return; } if(selected.equals(">")) { layout.next(cards); return; } if(selected.equals("Invia mail")) { layout.show(cards, "Invia mail"); return; } if(selected.equals("Esegui ricerche")) { layout.show(cards, "Esegui ricerche"); return; } if(selected.equals("About")) { layout.show(cards, "About"); return; } if(selected.equals("Links")) { layout.show(cards, "Links"); return; } if(selected.equals("FTP")) { layout.show(cards, "FTP"); return; } if(selected.equals("Cerca su host")) { layout.show(cards, "Cerca su host"); return; } } // --------------------------------------------------------------------------------------// Intercetta l evento di chiusura della finestra // L implementazione di windowListener pretende che comunque siano presenti // le diachiarazioni degli altri metodi. // --------------------------------------------------------------------------------------public public public public public public public } // --------------------------------------------------------------------------------------// Classe principale del programma (entry point) // Recupera i parametri specificati nel file HTML se no utilizza quelli di default // specificati nella dichiarazione delle variabili // --------------------------------------------------------------------------------------public { class javaCenter extends Applet = "www.bernardotti.al.it"; = "flavio@bernardotti.al.it"; = "www.bernardotti.al.it"; = "index.html"; void void void void void void void windowClosing(WindowEvent e) { windowOpened(WindowEvent e) {} windowClosed(WindowEvent e) {} windowDeiconified(WindowEvent e) {} windowDeactivated(WindowEvent e) {} windowActivated(WindowEvent e) {} windowIconified(WindowEvent e) {} dispose(); }
private String m_mailhost private String m_mailto private String m_ftpserver private String m_firstpage
private final String PARAM_mailhost = "mailhost"; private final String PARAM_mailto = "mailto"; private final String PARAM_ftpserver= "ftpserver"; private final String PARAM_firstpage= "firstpage"; // --------------------------------------------------------------------------------------// Recupera un argomento specifico // --------------------------------------------------------------------------------------String GetParameter(String strName, String args[]) { if (args == null) { return getParameter(strName); } int i; String strArg = strName + "="; String strValue = null; int nLength = strArg.length(); try { for (i = 0; i < args.length; i++) { String strParam = args[i].substring(0, nLength); if (strArg.equalsIgnoreCase(strParam)) { strValue = args[i].substring(nLength); if (strValue.startsWith("\"")) { strValue = strValue.substring(1); if (strValue.endsWith("\"")) strValue = strValue.substring(0, strValue.length() - 1); } break; } } } catch (Exception e) {} return strValue; } // --------------------------------------------------------------------------------------// Recupera i tre argomenti assegnandoli ciascuno alla propria variabile // --------------------------------------------------------------------------------------void GetParameters(String args[]) { String param = ""; param = GetParameter(PARAM_mailhost, args); if (param != null) m_mailhost = param; param = GetParameter(PARAM_mailto, args); if (param != null) m_mailto = param; param = GetParameter(PARAM_ftpserver, args); if (param != null) m_ftpserver = param; param = GetParameter(PARAM_firstpage, args); if (param != null) m_firstpage = param; } public void init() { GetParameters(null); new javaCenterFrame(this, m_mailhost, m_mailto, m_ftpserver, m_firstpage); } }
Dopo aver visto le classi principale e quella che gestisce il frame interessiamoci di vedere al classe che presenta a video una lista di WEB presenti in un file chiamato links.txt il quale viene identificato come una risorsa, aperto, letto ed inserito dentro una lista da cui potra essere selezionato. Copyright 2002 Flavio Bernardotti Tel. (39) 380 7097051
Ad esempio : www.bernardotti.al.it|WEB di chi ha scritto questa romanza| www.javasoft.com|Sito SUN dedicato al software Java|
Il file verra identificato come risorsa presente sul WEB mediante la costruzione del suo URL. Dopo averlo aperto mediante la classe stringTokenizer verra analizzato in modo da suddividere la denominazione del sito dalla sua descrizione. Mediante una classe di formattazione i dati verranno inseriti in una lista dalla quale sara possibile selezionare il sito a cui connettersi. La classe javaCenterForm proviene da una classe public domain trovata su internet.
Il suo compito e quello di eseguire formattazioni tipo quelle fatte dalla printf() del C.
La riga di programma che utilizza tale classe per creare la riga da inserire nella lista e la seguente : lista.add(new javaCenterForm("%-40s").form(address) + " " + descrizione); Mediante il metodo showDocument della classe applet verra aperta una nuova pagina del browser con la pagina del sito scelto. applet.getAppletContext().showDocument(u, "_blank");
class {
// -----------------------------------------------------------------------------------// Intercetta le azioni avvenute sugli oggetti registrati // mediante la funzione oggetto.addActionListener(this); // -----------------------------------------------------------------------------------public void actionPerformed(ActionEvent e) { String selected = e.getActionCommand(); if(selected.equals("Connetti")) { setCursor(new Cursor(Cursor.WAIT_CURSOR)); String choiceString = new String(lista.getItem(lista.getSelectedIndex())); StringTokenizer database = new StringTokenizer(choiceString, " "); String connessione = database.nextToken(); sito.setText(connessione); try { // -----------------------------------------------------------------------------------// Crea una risorsa URL data dal nome del sito // e si connette aprendo una pagina nuova del brwser // -----------------------------------------------------------------------------------URL u = new URL(connessione);
LA CLASSE URL
Una delle classi fondamentali, che abbiamo visto nel modulo precedente, e la classe URL. La classe URL rappresenta un puntatore ad una risorsa presente su un WEB la quale viene reperita utilizzando l Uniform Resource Locator. Una risorsa potrebbe essere un normalissimo file o directory od un oggetto piu complesso come ad esempio un interrogazione su un database. Un URL normalmente viene suddiviso in due parti HTTP://
Protocollo
www.bernardotti.al.it
Risorsa
La prima parte specifica il protocollo mentre la seconda la risorsa. Esistono diversi costruttori mediante i quali e possibile creare una risorsa URL. Il piu semplice e il seguente : URL sunSoft = new URL(http://www.javasoft.com/);
Esistono altri costruttori che permettono di specificare le risorse in modo differente, utilizzando anche il numero di porta se necessario.
Ad esempio : URL sunSoft = new URL(http, www.javasoft.com, /index.html); e equivalente a URL sunSoft = new URL(http://www.javasoft.com/index.html);
Ogni costruttore URL puo generare un eccezione legata al protocollo errato o alla risorsa sconosciuta. L eccezione puo essere intercettata con il seguente costrutto :
try { URL sunSoft = new URL(http://www.javasoft.com/); } catch(MalformedURLException e) { handler all eccezione } La classe URL contiene inoltre diversi metodi destinati a ricevere informazioni legate alla URL stessa. Fate attenzione che non e detto che tutte le informazioni debbano essere presenti.
Vediamo i seguenti metodi : getProtocol() getHost() Ritorna il protocollo Ritorna il nome dell host
Alcune volte dopo che e stata creata un URL e possibile utilizzare il metodo openConnection() per creare un collegamento tra il programma Java e l URL stesso. Per esempio e possibile creare una connessione con un sito, Altavista ad esempio, mediante il codice : try { URL urlTmp = new URL("http://www.altavista.digital.com/"); URLConnection urlCon = urlTmp.openConnection(); } catch (MalformedURLException e) {} catch (IOException e) {} Se la connessione ha avuto successo questa potra essere utilizzata per funzioni di lettura e di scrittura. Molte funzioni legate al reperimento di immagini, suoni, files ecc. necessitano dell URL. Ad esempio : public Image getImage(URL url) public Image getImage(URL url, String name) I seguenti metodi mostrano alcuni esempi pratici.
Image image1 = getImage(getCodeBase(), "imageFile.gif"); Image image2 = getImage(getDocumentBase(), "anImageFile.jpeg"); Image image3 = getImage(new URL("http://java.sun.com/graphics/people.gif"));
Esistono due metodi della classe Applet, utilizzati moltissime volte, che permettono di ricavare, in ordine : 1. 2. L URL della pagina che chiama l applet L URL dell applet
Le funzioni sono in ordine : Applet.getDocumentBase() Applet.getCodeBase() Come abbiamo appena visto i due metodi sono stati utilizzati nel punto in cui era necessario fornire come argomenti lURL dell host da cui era stato caricato l applet. LA CLASSE URLConnection
Questa classe contiene molti metodi utili quando si lavora con URL HTTP. Fate attenzione che si tratta di una classe astratta e quindi non puo essere istanziata direttamente. Invece di utilizzare un costruttore vedremo come puo essere utilizzato il metodo openConnection() della classe URL La seguente funzione mostra come eseguire la lettura sfruttando la classe URLConnection. Esempio :
import java.net.*; import java.io.*;
public class URLConnReadr { public static void main(String[] args) throws Exception { URL tmpUrl = new URL("http://www.altavista.digital.com/"); URLConnection URLConn = tmpUrl.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader(URLConn.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close();
Nella classe URLConnection esistono un grosso numero di metodi e variabili. Due di queste variabili e due metodi che settano queste variabili sono degni di nota in quanto permettono di eseguire funzioni di input e di output sulla connessione creata. In pratica le variabili sono : doOutput doInput A seconda del valore che viene settato (true/false) si indica che l applet vuole eseguire, in ordine, dell output e dell input sulla URLConnection. Queste variabili possono essere settate dai metodi : void setDoOutput(boolean) void setDoInput(boolean) Altri due metodi, uno visto nel codice in alto, permettono di ricavare rispettivamente un stream di output ed uno di input dall URLConnection. I due metodi sono : OutputStream getOutputStream() InputStream getInputStream() LA CLASSE InetAddress
Esistono alcune classi che spesso risultano essere utili come ad esempio la InetAddress la quale permette di creare e registrare degli indirizzi utilizzati da altre classi. Quest ultima classe di fatto non possiede costruttori pubblici ma in compenso dispone di diversi metodi statici che possono essere utilizzati per creare delle istanze della classe. Tutti i metodi sono statici e devono essere utilizzati nel seguente modo. InetAddress addr = InetAddress.getByName(www.javasoft.com); InetAddress addr = InetAddress.getLocalHost(); InetAddress addr[] = InetAddress.getAllByName(www.javasoft.com); Le precedenti funzioni generano un UnknownHostException se il sistema non e collegato a un DNS. Per DNS si intende Domain Name Server. In altre parole il TCP/IP permette di far riferimento agli host di una rete mediante appositi nomi invece di usare l indirizzo IP. In pratica il DNS e il metodo che ci permette di riferirci ad un sistema quello che normalmente costituito dal nomeHost.nomeDominio (i vari www.javasoft.com, www.bernardotti.al.it ecc.) Inoltre la classe InetAddress include numerose variabili e funzioni per memorizzare indirizzi host Internet. public String hostName public int address public String localHostName Questa variabile contiene il nome dell host nella forma www.xx.yy L indirizzo numerico dell host (x.y.z.j) Contiene il nome dell host locale ovvero quello del computer su cui viene eseguita l applicazione.
Dopo questa panoramica sulla classe URL utilizzata nella prima parte del programma vediamo una seconda parte ovvero quella che si interessa dell invio di messaggi all host. La classe e suddivisa in due parti. La prima crea la maschera video in cui viene richiesto di inserire l email del mittente e il testo del messaggio. Il server mail utilizzato per l invio viene specificato nei parametri della pagina HTML mediante la voce <param name=mailhost value=www.bernardotti.al.it> La seconda parte e quella invece che si interessa della creazione del messaggio e del suo invio.
Questo non significa che, dopo aver aperto un Socket su quella porta, tutto cio che verra scritto verra inviato come mail. I dati scritti su tale socket dovranno essere formattati in un determinato modo per essere considerati un messaggio valido e quindi per essere smistato. Le informazioni dovrebbero avere la seguente formattazione :
HELO host mittente MAIL FROM: mittente RCPT TO: ricevente DATA Messaggio (qualsiasi numero linee) . QUIT
Esiste una classe in sun.net.smtp che permette la gestione del messaggio. Nel nostro modulo riscriveremo completamente la parte che si interessa della creazione e dell invio del messaggio in modo tale da vedere in funzione alcune classi legate alla gestione della rete. Parte 3 file javaCenter.java
// -------------------------------------------------------------------------------// Classe che crea il messaggio e lo invia // In pratica svolge le funzioni della classe sun.net.smtp // -------------------------------------------------------------------------------class javaCenterSmtp { static final int DEFAULT_PORT = 25; static final String EOL = "\r\n"; protected DataInputStream reply = null; protected PrintStream send = null; protected Socket sock = null; public javaCenterSmtp( String hostid) throws UnknownHostException, IOException { this(hostid, DEFAULT_PORT); } public javaCenterSmtp( String hostid, int port) throws UnknownHostException, IOException { // -------------------------------------------------------------------------------// Apre un socket sulla porta 25 // La porta 25 e relativa al demone di gestione mail // -------------------------------------------------------------------------------sock = new Socket( hostid, port ); reply = new DataInputStream( sock.getInputStream() ); send = new PrintStream( sock.getOutputStream() ); String rstr = reply.readLine(); if (!rstr.startsWith("220")) throw new ProtocolException(rstr); while (rstr.indexOf('-') == 3) { rstr = reply.readLine(); if (!rstr.startsWith("220")) throw new ProtocolException(rstr);
Questa e la classe che si interessera fisicamente del messaggio. La classe che segue invece e quella che gestisce la maschera dei dati e che richiama la classe appena vista. In questa parte ritroviamo le funzioni che settano il gestore di layout e che posizionano gli oggetti come i pulsanti e i campi di testo in cui inserire i dati a video. Parte 4 file javaCenter.java
// -------------------------------------------------------------------------------// Gestisce la maschera dei dati // -------------------------------------------------------------------------------class javaCenterSendMail extends Panel implements ActionListener
Per la gestione della formattazione dei campi e stata utilizzata una classe che semplifica l utilizzo del gestore di layout GridBagLayout ed una per la visualizzazione dei messaggi temporanei. Il posizionamento dei vari pulsanti, campi di testo ecc. avverra nel seguente modo.
Button cerca = new Button("Cerca"); constrainer.constrain(cerca, 50, 4, 10, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(cerca);
Prima di vedere le classi legate all uso della rete utilizzate nei due moduli precedenti riporto queste due classi. Parte 5 file javaCenter.java
// -------------------------------------------------------------------------------// Dialog creata per visualizzare messaggi temporanei // quali ad esempio segnalazioni di errore. // Viene creata a partire dalla classe Dialog con il solo // pulsante OK, che permette di uscirne dopo aver letto il testo.
// -------------------------------------------------------------------------------class javaCenterMSGBox extends Dialog implements ActionListener, WindowListener { public javaCenterMSGBox(Frame parent, String title, String message) { super(parent, title, true); setLayout(new FlowLayout(FlowLayout.CENTER)); Label testMsg = new Label(message); add(testMsg); Button ok = new Button("Ok"); add(ok); ok.addActionListener(this); addWindowListener(this); setBackground(Color.lightGray); setSize(400, 100); setVisible(true); }
LA CLASSE Socket
Nella parte che si interessava dell invio del messaggio cera la seguente parte di codice :
sock = new Socket( hostid, port ); reply = new DataInputStream( sock.getInputStream() ); send = new PrintStream( sock.getOutputStream() );
Un socket puo essere considerato come il punto di connessione a due vie esistente tra due programmi che girano in rete. In altre parole un socket e la rappresentazione in Java di una connessione TCP. In pratica quando si vuole eseguire un collegamento ad un sistema in rete si conosce l indirizzo di questo. Mediante il numero di porta e possibile richiedere la connessione ad un software specifico che gira su questa macchina. Nel nostro caso abbiamo utilizzato il socket aperto utilizzando il nome del server mail e la porta 25 (quella del demone mail) per aprire uno stream di output sul quale scrivere i dati relativi al messaggio da inviare. Come e possibile vedere anche dalle due righe di codice appena riportate la fase di scrittura si suddivide in due fasi : 1 2 apertura del socket sul host + numero di porta apertura in scrittura di uno stream
Come avrete visto gli stream aperti sono di fatto due. Uno per scriverci i dati del messaggio e l altro per leggere le repliche del demone mail. E possibile utilizzare la classe socket per la creazione di software client/server. Supponiamo che sul server giri un programma relativo ad un gioco che apre un socket su una fatidica porta 2222. Qualsiasi client potra comunicare con tele software aprendo anchesso un socket utilizzando il nome dell host e il numero di porta 2222. Il software sul sever www.aquilotto.com avra la forma : Socket sock = new Socket(2222);
Sul client invece si avra : Socket sock = new Socket(www.aquilotto.com, 2222); Chiaramente questo e il concetto di base in quanto nel caso di una gestione reale multiutente si dovrebbe eseguire un implementazione tramite thread. LA CLASSE ServerSocket
Questa classe rappresenta un connessione TCP in attesa di ricezione. Non appena viene ricevuta una richiesta di connessione la classe ServerSocket restituisce un oggetto Socket. Ad esempio : ServerSocket servSock = new ServerSocket(5555); definisce un server che monitorizza la porta 5555.
class {
GridBagConstraints constraints = new GridBagConstraints(); javaCenterConstrainer constrainer = new javaCenterConstrainer(this, constraints); constrainer.getDefaultConstraints().insets = new Insets(5, 5, 5, 5); GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag); Label strToSearch = new Label("Ricerca su motore :"); constrainer.constrain(strToSearch, 0, 2, 25, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(strToSearch); c = new Choice(); constrainer.constrain(c, 25, 2, 25, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(c); c.addItem("1Blink");
public void actionPerformed(ActionEvent e) { String choiceString; String selected = e.getActionCommand(); if(selected.equals("Cerca")) { String s = ""; String s1 = tf.getText(); String s2 = ""; s2 = s1.replace(' ', '+'); tf.setText(s2); s = c.getSelectedItem(); if(s == "Cade Brazil") if(tf.getText().length() > 0) s1 = "http://busca.cade.com.br/scripts/engine.exe?p1=" + tf.getText() + "&p2=1&p3=1"; else if(tf.getText().length() < 1) s1 = "http://www.cade.com.br/"; if(s == "Euroseek") if(tf.getText().length() > 0) s1 = "http://www.euroseek.net/query?iflang=uk&query=" + tf.getText() + "&domain=world&lang=world"; else if(tf.getText().length() < 1) s1 = "http://www.euroseek.net/page?ifl=uk"; if(s == "Cari Malaysia") if(tf.getText().length() > 0) s1 = "http://206.184.233.23/cariurl.cgi?" + tf.getText(); else if(tf.getText().length() < 1) s1 = "http://www.cari.com.my/"; if(s == "Oomph! Korea") if(tf.getText().length() > 0) s1 = "http://www.oomph.net/~dasen21/dasencgi/brief.cgi?v_db=1&v_userid=158&v_query=" + tf.getText() + "&v_hangul=1&v_expert=Search"; else if(tf.getText().length() < 1) s1 = "http://www.oomph.net/"; if(s == "Goo Japan") if(tf.getText().length() > 0) s1 = "http://www.goo.ne.jp/default.asp?MT=" + tf.getText() + "&SM=MC&WTS=ntt&DE=2&DC=10&_v=2"; else if(tf.getText().length() < 1) s1 = "http://www.goo.ne.jp/"; if(s == "1Blink") if(tf.getText().length() > 0) s1 = "http://www.1blink.com/search.cgi?q=" + tf.getText(); else if(tf.getText().length() < 1) s1 = "http://www.1blink.com/"; if(s == "Savvy Search") if(tf.getText().length() > 0) s1 = "http://williams.cs.colostate.edu:1969/nph-search?KW=" + tf.getText() + "&classic=on&t1=x&t2=x&t3=x&t4=x&t5=x&t6=x&t7=x&t8=x&t9=x&t10=x&Boolean=AND&Hits=10&Mode=MakePlan&df=nor mal&AutoStep=on"; else if(tf.getText().length() < 1) s1 = "http://www.cs.colostate.edu/~dreiling/smartform.html"; if(s == "Canada") if(tf.getText().length() > 0) s1 = "http://results.canada.com/search/search.asp? RG=world&SM=must%3Awords&QRY=" + tf.getText() + "&PS=10&DT=1&GO.x=30&GO.y=8"; else if(tf.getText().length() < 1) s1 = "http://www.canada.com/"; if(s == "KHOJ") if(tf.getText().length() > 0) s1 = "http://www.khoj.com/bin/khoj_search?searchkey=" + tf.getText(); else if(tf.getText().length() < 1) s1 = "http://www.khoj.com/"; if(s == "AliWeb") if(tf.getText().length() > 0) s1 = "http://www.aliweb.com/form2.pl?query=" + tf.getText() + "&showdescription=on&titlefield=on&descriptionfield=on&keywordfield=on&urlfield=on&hits=20&domain=&searchtype=Wh ole+Word&types=Any"; else if(tf.getText().length() < 1) s1 = "http://www.aliweb.com/"; if(s == "Liszt") if(tf.getText().length() > 0)
Questa parte assume un notevole interesse in quanto dalla fusione di tre moduli presenti in questo programma potrebbero nascere delle idee interessanti. Ad esempio un altra funzione che vedremo e una che permette di analizzare delle strutture di pagine HTML indicando quelle che contengono parole o frasi specificate. Programmando questo modulo in modo tale che l analisi la faccia su pagine ritornate dai motori di ricerca su indicati si potrebbe creare un programma che invia automaticamente una
class javaCenterFTP extends Panel implements ActionListener { private TextField server = null; private TextField directory = null; private TextField fFile = null; private TextArea lsMessage = null; private Button bServer; private Button download; private Button chDir; private FtpClient fcAluFtp=new FtpClient(); private TelnetInputStream tisList=null; private TelnetInputStream tisGet=null; private TelnetOutputStream tosPut=null; public { javaCenterFTP(String ftpServer) super(); GridBagConstraints constraints = new GridBagConstraints(); javaCenterConstrainer constrainer = new javaCenterConstrainer(this, constraints); constrainer.getDefaultConstraints().insets = new Insets(5, 5, 5, 5); GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag); Label strTmp = new Label("Server :"); constrainer.constrain(strTmp, 0, 5, 11, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(strTmp); server = new TextField(ftpServer, 40); constrainer.constrain(server, 11, 5, 40, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(server); bServer = new Button("Connetti"); constrainer.constrain(bServer, 51, 5, 10, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(bServer); strTmp = new Label("Directory:"); constrainer.constrain(strTmp, 0, 6, 11, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(strTmp); directory = new TextField("/pub", 40); constrainer.constrain(directory, 11, 6, 40, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(directory); chDir = new Button("CHDIR"); constrainer.constrain(chDir, 51, 6, 10, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(chDir); strTmp = new Label("File :"); constrainer.constrain(strTmp, 0, 7, 11, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(strTmp); fFile = new TextField("", 40); constrainer.constrain(fFile, 11, 7, 40, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); add(fFile); download = new Button("Preleva"); constrainer.constrain(download, 51, 7, 10, 1, 1, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST);
I metodi appena visti utilizzano quelli della classe sun.net.ftp per eseguire la connessione al server FTP, per eseguire la navigazione sulle directory del sistema e per prelevare i files. Come potete vedere a seguito di una richiesta di cambio directory viene eseguita anche una DIR (ls) in modo tale da mostrare i contenuti del nuovo posizionamento. Avrete notato che l output ricevuto tramite uno stream TELNET viene visualizzato dentro ad una TextArea ovvero ad un campo di edit multiriga che viene adibito, nel programma, a maschera di visualizzazione dei dati che giungono dall host a cui si e connessi. Il programma utilizza sempre il LOGIN anonymous e la mia EMAIL come password in quanto si suppone che ci si voglia connettere a sistemi pubblici che normalmente si attengono a questo sistema. Se vi interessa effettuare il login su host con LOGIN, e quindi PASSWORD, dedicate potete modificare il programma aggiungendo alla maschera di inserimento dei dati anche il campo per contenere il primo dato e un altro per contenerci la password.
fcAluFtp.login("anonymous","flavio@bernardotti.al.it");
Il precedente codice dovra essere modificato in modo tale che gli argomenti diventino quelli letti dai campi aggiunti. Per gestire un flusso di dati si in input che in output viene utilizzato uno stream Telnet. Uno stream Telnet puo essere ottenuto utilizzando le apposite classi sun.net. Difatti sono presenti le classi TelnetOutputStream e TelnetInputStream per gestire flussi di dati.
tmpLista = new java.awt.List(7, false); tmpLista.setForeground(new Color(0,255,0)); tmpLista.setBackground(new Color(0,60,0)); tmpLista.addItemListener(this); messaggi = new TextArea(5, 30); panel.add(tmpLista); panel.add(messaggi); tmpLista.addItemListener(this); add(panel, "South"); } public void stop() { th = null; } public void run() { register(indexpage ); Search(textfield1.getText() , criteria , indexpage ); stopThread(); } public void startThread() { if( th != null ){ th.stop(); th = null; } th = new Thread( this ); th.start(); } public void stopThread() { button1.setLabel( "Cerca" ); messaggi.appendText("Nessuna altra pagina trovata.\r\n"); messaggi.appendText("Eseguite un doppio click su un eventuale url trovato.\r\n"); if( th != null ) { try{ th.stop(); }catch( Exception e ){} th = null; } } void Search( String search, String criteria, String url ) { String content = ""; try{ content = readURL( url ); } catch( Exception e ) { return; } Enumeration links = parseLinks( content ); messaggi.appendText("Ricerca su " + url + " di " + search + " (" + criteria + ")\r\n"); if(criteria.equalsIgnoreCase( "qualsiasi parola" ) && matchAny( search, content ) ) report( url ); else if( criteria.equalsIgnoreCase( "tutte le parole" ) && matchAll( search, content ) ) report( url ); else if( criteria.equalsIgnoreCase( "frasi" ) && matchPhrase( search, content ) ) report( url ); while( links.hasMoreElements() ) Search( search, criteria, (String)links.nextElement() ); } boolean matchAny( String search, String content ) { String s = search.toLowerCase(); String c = content.toLowerCase(); StringTokenizer tok = new StringTokenizer( s , ", " , false ); while( tok.hasMoreTokens() ){
L esempio visto costituito da 8 pezzi. Dato che nella versione 1.2 del JDK e stata inserita un altra classe List la dichirazione List del AWT creava un errore di ambiguita. Per sopperire al problema la dichiarazione, dove serve e stata fatta con : java.awt.List lista = new java.awt.List(10, false); L applet puo essere compilato sia con il JDK 1.1 (o con 1.2) oppure con il compilatore Microsoft 1.12 (anche con la 6.0). GESTIONE ECCEZIONI
Nelle argomentazioni viste precedentemente abbiamo utilizzato l intercettazione delle eccezioni che potevano essere generate dall utilizzo delle varie classi. Vediamo ora di approfondire il discorso in quanto l argomento ricopre un ruolo molto importante. Avevamo accennato, parlando delle URL, ad un eccezione che veniva generato nel caso in cui si verificava l impossibilita di accedere, per problemi di errata definizione del formato, ad una risorsa. L eccezione in questione era la MalformedURLException.
Errore del protocollo telnet Errore nel protocollo smtp Errore accedendo al server FTP Errore del protocollo FTP Errore del protocollo Nntp
Inizialmente, quando parlavamo della struttura della rete, avevamo visto la definizione del protocollo UDP e avevamo anche detto che esisteva una serie di classi che erano apposite per tale protocollo. Si trattava delle classi per i datagrammi. LA CLASSE DATAGRAMMA
Inizialmente avevamo detto che i datagrammi vengono utilizzati per inviare in modo indipendente dei pacchetti di dati da un applicazione ad un'altra senza garantirne l arrivo. I pacchetti di dati inviati tramite datagrammi in genere sono indipendenti. Per fare un esempio pratico vediamo due moduli, uno per il server e uno per il client, che permettono di inviare le informazioni degli utenti collegati ad un sistema Unix. Supponiamo che esista un programma che a tempi regolari esegua un who (istruzione Unix per vedere l elenco degli utenti collegati al sistema) e che scriva i dati in un file denominato users.txt. Il programma server dovra attendere una richiesta di invio di un datagramma da parte di un software client e dovra inviare il contenuto del file.
import java.io.*; import java.net.*; import java.util.*; public class whoClient { public static void main(String[] args) throws IOException { if (args.length != 1) { System.out.println("Usage: java whoClient <hostname>"); return; } // Crea il datagramma DatagramSocket socket = new DatagramSocket(); byte[] buffer = new byte[512]; InetAddress address = InetAddress.getByName(args[0]); // Invia la richiesta DatagramPacket packet = new DatagramPacket(buffer, buffer.length, address, 5225); socket.send(packet); // Prende la risposta packet = new DatagramPacket(buffer, buffer.length); socket.receive(packet); // Lo visualizza i dati ricevuti String received = new String(packet.getData(), 0); System.out.println("User(s) connected: " + received); socket.close(); } }
Con la versione 1.2 del JDK i packages legati alla gestione della rete sono ulteriormente aumentati facendo diventare il numero dei metodi a disposizione una cosa enorme. Veramente un infinita di metodi sufficenti a perdersi dentro. A peggiorare la situazione ci sono anche le classi create da programmatori e software house che invadono il mercato sia shareware che commerciale. Sun esce con la versione 1.2 ed aggiunge le classi Swing e JFC Microsoft arriva con la sua 3.0 e inserisce AFC. Ogni botta sono centinaia di metodi che si aggiungono a quelli gia esistenti. Senza contare che quello che oggi e recentissimo domani e sorpassatissimo. Con Java e proprio il caso di dire : chi vivra vedra !
Per fare un esempio pratico. Anni fa ricevetti una commessa da Telecom (allora SIP) la quale aveva questo problema. La gestione del personale e quindi presenze, turni ecc., veniva fatta in tutta Italia tramite terminali che permettevano di inserire i dati dentro ai vari Mainframe che accentravano l'elaborazione di questi. Le varie agenzie quindi inserivano tutte le informazioni dentro ai sistemi 3090 tramite questi terminali 3270 su reti IBM SNA e non potevano fare nessuna elaborazione locale delle informazioni. La soluzione per permettere di disporre localmente delle informazioni sarebbe stata quella di poter accedere agli archivi del 3090 IBM, cosa impossibile in quanto il centro di calcolo non dava questa disponibilit, anzi trattava i suoi dati come se fossero TOP SECRET. Allora le soluzioni alternative sarebbero state quelle di digitare due volte i dati, una volta per inserirli nel database locale e un altra volta per metterli nel mainframe.
Scrivendo un linguaggio che gestisse queste problematiche si sarebe facilmente potuto scrivere altre applicazioni per questo tipo di architetture. Comunque questo era solo un esempio in quanto la scrittura di piccoli linguaggi diventa utile per tutti quei casi in cui ci sono problemi ricorrenti. Che cosa significa scriversi un linguaggio dedicato ? Chiaramente parliamo di strutture semplici senza andare in complicazioni particolari. Scriversi un linguaggio orientato significa analizzare i vari problemi che questo deve risolvere e scriversi una tabella sintattica e semantica che descriva le strutture di questo linguaggio. Un linguaggio inanzi tutto composto da vocaboli che possiamo definire con il termine di TOKEN i quali possono essere combinati secondo certe regole semantiche. Prendiamo un operazione di selezione delle informazioni da database. Il token sar SELEZIONA il quale potr essere seguito da un nome di un campo oppure da un carattere * atto a indicare che si vogliono estrarre tutti i campi. Se il termine dopo SELEZIONA * allora il token successivo pu essere solo il nome del DATABASE da cui si vogliono estrarre le informazioni. (1) Nel caso in cui sia un campo di database il token dopo pu essere una virgola (,) a separazione oppure il nome del database.
Nel caso che sia una virgola si estrae un altro token e si ricomincia la valutazione dal punto (1). Quindi le cose da fare per scriversi un linguaggetto sono :
Scriversi il flusso del linguaggio in base ai vari costrutti Scriversi un programma che carichi tutto il programma in un buffer e che possieda una funzione che estrae un TOKEN alla volta (GetToken). Scriversi le varie funzionalita' che devono essere eseguite quando si arriva ad interepratre una certa cosa.
Supponiamo di avere un costrutto del linguaggio che :
SCRIVIAVIDEO [stringa] Chiamiamo GetToken il quale ci restituisce SCRIVIAVIDEO. Capiamo che si tratta di una funzione che deve scrivere la stringa successiva a video. Richiamiamo GetToken il quale ci restituisce la stringa. A questo punto chiamiamo un funzione che stampa a video alla quale passeremo come argomento il secondo token. Il nostro linguaggio dovr possedere anche un analizzatore metematico a cui passare funzioni del tipo : SCRIVIAVIDEO 34*25+2-1 Questa parte di sorgente incorpora il parser matematico. L'ultima funzione in basso entry() legge ciclicamente un funzione e ne stampa il risultato.
char #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define
far buffer[16384]; ERROR DELIMITER VARIABLE NUMBER INSTRUCTION LABEL COUNTER FINISHED INSTR_SE INSTR_INIZIOSE INSTR_FINESE INSTR_ALTRIMENTI INSTR_ESEGUI INSTR_VAIA INSTR_STAMPA 0 2 5 7 0 2 4 6 6 1 3 5 1 3 4
char *funcstr[] = { "IF", "BEGIN", "END", "ELSE", "RUN", "GOTO", "PRINT", "" }; static struct label { char labname[12]; char *prgptr; } lbl[50]; static char char int int void int numlabel = 0; *prog; token[80]; tok_type; tok_istr; level1(float *);
void { }
float vars[26] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static int is_in(char ch, char *s) { while(*s) if(*s++==ch) return 1; return 0; } static int isdelim(char c) { if(is_in(c, " +-*/%^=()") || c == 9 || c == '\r' || c == 0) return 1; return 0; } static void searchfunction(void) { register i = 0; while(funcstr[i]) { if(!lstrcmp(token,funcstr[i])) { tok_istr = i; return; } ++i; } tok_istr = ERROR; } static void get_token(void) { register char *temp; tok_type = 0; temp = token; while(isspace(*prog)) ++prog; if(*prog == '\0') { tok_type = FINISHED; return; } if(is_in(*prog, "+-/%*^=()")) { tok_type = DELIMITER; *temp++ = *prog++; } if(*prog == '!') { while(!isdelim(*prog)) *temp++ = *prog++; tok_type = VARIABLE; } if(isdigit(*prog)) { while(!isdelim(*prog)) *temp++ = *prog++; tok_type = NUMBER; } if(*prog == ':') { while(!isdelim(*prog))
} static float find_var(char *s) { if(!isalpha(*s)) { serror(1); return (float) 0.0; } return vars[*token - 'A']; } static void putback(void) { char *t; t = token; for(;*t;t++) prog--; } static void unary(char o, float *r) { if(o == '-') *r = -(*r); } static void arith(char o, float *r, float *h) { float t, ex; switch(o) { case '-': *r = *r - *h; break; case '+': *r = *r + *h; break; case '*': *r = *r * *h; break; case '/': *r = *r / *h; break; case '%': t = *r / *h; *r = *r - (t * *h); break; case '^': ex = *r; if(*h == 0) { *r = (float) 1.0; break;
} }
static void level2(float *result) { register char op; float hold; level3(result); while((op = *token) == '+' || op == '-') { get_token(); level3(&hold); arith(op, result, &hold); } } static void level1(float *result) { int slot, ttok_type; char temp_token[80]; if(tok_type == VARIABLE) { lstrcpy(temp_token, token); ttok_type = tok_type; slot = *token - 'A'; get_token(); if(*token != '=') { putback(); lstrcpy(token, temp_token); tok_type = ttok_type; } else { get_token(); level2(result); vars[slot] = *result; return; } } level2(result); } static void get_exp(float *result) { get_token(); if(!*token) return; level1(result); } void { entry(HWND hDlg)
float answer; register i = 0; while(1) { prog = buffer; if(SendMessage(GetDlgItem(hDlg, 103), EM_GETLINE, i, (LONG) (LPSTR) buffer) <= 0) break; get_exp(&answer); wsprintf(buffer, "%ld\n", (long) answer); SetDlgItemText(hDlg, 118, buffer); ++i;
In alto viene gestita una tabella dei simboli che viene utilizzata dalla funzione GetToken la quale quando viene chiamata restituisce non solo il TOKEN ma anche il tipo del token.
staticvoid get_token(void) { register char *temp; tok_type = 0; temp = token; while(isspace(*prog)) ++prog; if(*prog == '\0') { tok_type = FINISHED; return; } if(is_in(*prog, "+-/%*^=()")) { tok_type = DELIMITER; *temp++ = *prog++; } if(*prog == '!') { while(!isdelim(*prog)) *temp++ = *prog++; tok_type = VARIABLE; } if(isdigit(*prog)) { while(!isdelim(*prog)) *temp++ = *prog++; tok_type = NUMBER; } if(*prog == ':') { while(!isdelim(*prog)) *temp++ = *prog++; tok_type = LABEL; } if(*prog == '$') { while(!isdelim(*prog)) *temp++ = *prog++; tok_type = COUNTER; } if(isalpha(*prog)) { searchfunction(); while(!isdelim(*prog)) *temp++ = *prog++; tok_type = INSTRUCTION; } *temp = '\0'; } Come potete vedere in alto anche i tipi di TOKEN sono definiti. #defineERROR0 #defineDELIMITER1 #defineVARIABLE2 #defineNUMBER3 #defineINSTRUCTION4 #defineLABEL5 #defineCOUNTER6 #defineFINISHED7 #defineINSTR_SE0
incrementato. Come potete vedere se il carattere puntato ad prog e' ! allora continua a leggere il nome della variabile per cui al ritorno da GetToken avremo in tok_type il valore VARIABLE e in token il valore del token. Se ci fosse un costrutto del tipo : STAMPA !A chiameremmo la prima volta GetToken il quale ci restituirebbe : tok_type = INSTRUCTION token = STAMPA da cui capiremmo che abbiamo a che fare con un istruzione e precisamente con STAMPA. Il nostro diagramma logico del linguaggio ci potrebbe dire che dopo a tale costrutto potremmo avere una variabile, una stringa o un numero, negli altri casi ci sarebbe errore. Richiamiamo GetToken la quale trovando !A ci restituirebbe : tok_type = VARIABLE token = NOMEVARIABILE Dopo aver visto che si tratta di una variabile potremmo volere che questa valutazione venisse fatta dall'analizzatore matematico.
Quando si chiama GetToken il puntatore del programma viene spostato all'istruzione successiva.
static void putback(void) { char *t; t = token; for(;*t;t++) prog--; } putback fa in modo che il programma torni al token precedente per cui dopo aver trovato la variabile faciamo arretrare il programma e richiamiamo il parser matematico. static void get_exp(float *result) { get_token(); if(!*token)
Come abbiamo visto a questo punto possiamo inserire qualsiasi funzione specificando la sua sintassi e scrivendo il codice che deve essere eseguito. Chiaramente le funzionalit nel nostro caso dovranno essere implementate o mediante una libreria socket oppure utilizzando wincap. A seconda della scelta fatta dovremo aggiungere anche alcune tipologie complesse che sono visualizzabili come strutture non come variabili numeriche o stringa normali. Ma ora iniziamo a creare la sintassi del linguaggio e le loro funzioni di gestione. Partiamo da quelle legate alla gestione dei canali di comunicazione.
0000B7 0000BB 0000BC 0000C0 0000C1 0000C5 0000C6 0000C8 0000C9 0000CA 0000CC 0000CD 0000D0 0000D1 0000D2 0000D3 0000D4 0000D7 0000D8 0000DD 0000DE 0000E1 0000E2 0000E3 0000E4 0000E6 0000E8 0000E9 0000ED 0000EE 0000EF 0000F0 0000F2 0000F3 0000F4 0000F6 0000F8 0000FB 0000FD 0000FF 000102 000143 000163 000168 0001C8 0001FA 000204 000205 000216 000288 0003C6 000400 0004AC 000502 00059A 0005A8 00060D
Dove Fastnet TRI-DATA Systems Inc. Netway products, 3274 emulators Allen-Bradley Western Digital now SMC (Std. Microsystems Corp.) Olicom A/S Farallon Computing Inc HP Intelligent Networks Operation (formerly Eon Systems) Altos Emulex Terminal Servers, Print Servers LANcity Cable Modems (now owned by BayNetworks) Densan Co., Ltd. Industrial Research Limited Develcon Electronics, Ltd. Adaptec, Inc. "Nodem" product SBE Inc Wang Labs PureData Dartmouth College (NED Router) old Novell NE1000's (before about 1987?) (also 3Com) Gould Unigraph Hitachi (laptop built-in) Acer Counterpoint Integrated Micro Products Ltd mips? Aptor Produits De Comm Indust Accton Technology Corporation ISICAD, Inc. April Network Designers Limited [also KNX Ltd, a former division] Alantec Samsung Spider Communications (Montreal, not Spider Systems) Gandalf Data Ltd. - Canada Allied Telesis, Inc. A.M.C. (Applied Microsystems Corp.) DEC Rechner zur Kommunikation High Level Hardware (Orion, UK) Camtec Electronics (UK) Ltd. BBN (Bolt Beranek and Newman, Inc.) internal usage (not registered) IEEE 802 NDC (National Datacomm Corporation) W&G (Wandel & Goltermann) [incorrect according to W&G] Thomas Conrad Corp. Compaq (PageMarq printers) Novell NE3200 Hamilton (Sparc Clones) ESI (Extended Systems, Inc) print servers Global Village (PCcard in Mac portable) Morning Star Technologies Inc Lexmark (Print Server) IBM PCMCIA Ethernet adapter. Apple (PCI bus Macs) PowerComputing (Mac clone) PowerComputing Mac clones Hewlett-Packard JetDirect token-ring
interfaces IBM RISC6000 system Cisco Cisco Racal-Datacom Cisco 2511 Token Ring Technically Elite Concepts Fermilab Compaq Cisco Systems Cisco 75xx Cisco Cisco Cisco 5000 3Com 3C905-TX PCI Cisco 5500 Router Ambicom (was Tandy?) Cisco Kabel Lexmark (Print Server) Cable & Computer Technology Adastra Systems Corp Canopus Co Ltd Orbotech Realtek Nbase Control Technology Inc (Industrial Controls 002025 and Network Interfaces) 002028 Bloomberg ATML (Advanced Telecommunications 00202B Modules, Ltd.) IBM (International Business Machines) 002035 mainframes, Etherjet printers 002036 BMC Software 002042 Datametrics Corp 002045 SolCom Systems Limited 002048 Fore Systems Inc 00204B Autocomputer Co Ltd 00204C Mitron Computer Pte Ltd 002056 Neoproducts 002061 Dynatech Communications Inc 002063 Wipro Infotech Ltd 002066 General Magic Inc 002067 Node Runner Inc 00206B Minolta Co., Ltd Network printers 002078 Runtop Inc 3COM SuperStack II UPS management 002085 module 00208A Sonix Communications Ltd 00208B Focus Enhancements 00208C Galaxy Networks Inc 002094 Cubix Corporation 0020A5 Newer Technology 0020A6 Proxim Inc 0020AF 3COM Corporation 0020B6 Agile Networks Inc 0020B9 Metricom, Inc. 0020C5 Eagle NE2000 0020C6 NECTEC Versalynx Corp. "The One Port" terminal 0020D0 server 0020D2 RAD Data Communications Ltd 0020D3 OST (Ouet Standard Telematique) 0020D8 NetWave 0020DA Xylan 0020DC Densitron Taiwan Ltd PreMax PE-200 (PCMCIA NE2000-clone 0020E0 card, sold by InfoExpress) 000629 00067C 0006C1 000701 00070D 000852 000855 0008C7 001011 00101F 00102F 00104B 001079 00107A 0010F6 001700 002000 002008 00200C 002011 002017 002018 00201A
0020E5 0020EE 0020F6 0020F8 004001 004005 004009 00400B 00400C 00400D 004010 004011 004013 004014 004015 004017 00401C 00401F 004020 004023 004025 004026 004027 004028 00402A 00402B 00402F 004030 004032 004033 004036 004039 00403C 004041 004043 004048 00404C 00404D 00404F 004050 004052 004054 004057 004059 00405B 00405D 004066 004067 004068 004069 00406A 00406E 00406F 004072 004074 004076 004078 00407F 004082 004085 004086 004087
Apex Data Gtech Corporation Net Tek & Karlnet Inc Carrera Computers Inc Zero One Technology Co Ltd (ZyXEL?) TRENDware International Inc.; Linksys; Simple Net; all three reported Tachibana Tectron Co Ltd Crescendo (now owned by Cisco) General Micro Systems, Inc. LANNET Data Communications Sonic Mac Ethernet interfaces Facilities Andover Environmental Controllers NTT Data Communication Systems Corp Comsoft Gmbh Ascom XCd XJet - HP printer server card AST Pentium/90 PC (emulating AMD EISA card) Colorgraph Ltd Pilkington Communication Logic Corporation Molecular Dynamics Melco Inc SMC Massachusetts [Had:Sigma (?), maybe the "S"?] Netcomm Canoga-Perkins TriGem Xlnt Designs Inc (XDI) GK Computer Digital Communications Addtron Technology Co., Ltd. TribeStar Optec Daiichi Denko Co Ltd Forks, Inc. Fujikura Ltd. Nokia Data Communications SMD Informatica S.A. Hypertec Pty Ltd. Telecomm Techniques Space & Naval Warfare Systems Ironics, Incorporated Star Technologies Inc Thinking Machines Corporation Lockheed-Sanders Yoshida Kogyo K.K. Funasset Limited Star-Tek Inc Hitachi Cable, Ltd. Omnibyte Corporation Extended Systems Lemcom Systems Inc Kentek Information Systems Inc Corollary, Inc. Sync Research Inc Applied Innovation Cable and Wireless AMP Incorporated Wearnes Automation Pte Ltd Agema Infrared Systems AB Laboratory Equipment Corp SAAB Instruments AB Michels & Kleberhoff Computer Ubitrex Corporation
004088 00408A 00408C 00408E 00408F 004090 004091 004092 004094 004095 004096 00409A 00409C 00409D 00409E 00409F 0040A4 0040A6 0040AA 0040AD 0040AE 0040AF 0040B4 0040B5 0040B6 0040B9 0040BD 0040C1 0040C2 0040C3 0040C5 0040C6 0040C7 0040C8 0040CC 0040CF 0040D2 0040D4 0040D7 0040D8 0040DC 0040DF 0040E1 0040E2 0040E3 0040E5 0040E7 0040E9 0040EA 0040ED 0040F0 0040F1 0040F4 0040F5 0040F6 0040F9 0040FA 0040FB 0040FD 0040FF 004F49 004F4B 00504D
Mobuis NuBus (Mac) combination video/EtherTalk TPS Teleprocessing Sys. Gmbh Axis Communications AB CXR/Digilog WM-Data Minfo AB Ansel Communications PC NE2000 compatible twisted-pair ethernet cards Procomp Industria Eletronica ASP Computer Products, Inc. Shographics Inc Eagle Technologies [UMC also reported] Telesystems SLW Inc Network Express Inc Transware DigiBoard Ethernet-ISDN bridges Concurrent Technologies Ltd. Lancast/Casat Technology Inc Rose Electronics Cray Research Inc. Valmet Automation Inc SMA Regelsysteme Gmbh Delta Controls, Inc. Digital Products, Inc. (DPI). 3COM K.K. Video Technology Computers Ltd Computerm Corporation MACQ Electronique SA Starlight Networks Inc Bizerba-Werke Wilheim Kraut Applied Computing Devices Fischer and Porter Co. Micom Communications Corp. Fibernet Research, Inc. Danpex Corporation Milan Technology Corp. Silcom Manufacturing Technology Inc Strawberry Tree Inc Pagine Corporation Gage Talker Corp. Studio Gen Inc Ocean Office Automation Ltd Tritec Electronic Gmbh Digalog Systems, Inc. Marner International Inc Mesa Ridge Technologies Inc Quin Systems Ltd Sybus Corporation Arnos Instruments & Computer Accord Systems, Inc. PlainTree Systems Inc Network Controls International Inc Micro Systems Inc Chuo Electronics Co., Ltd. Cameo Communications, Inc. OEM Engines Katron Computers Inc Combinet Microboards Inc Cascade Communications Corp. LXE Telebit Corporation Personal NetBlazer Realtek Pine Technology Ltd. Repotec Group
00504E 006008 006009 006025 00602F 00603E 006047 006052 00605C 006067 006070 006083 00608C 006094 006097 0060B0 008000 008001 008004 008005 008006 008007 008009 00800D 00800F 008010 008012 008013 008015 008016 008017 008019 00801A 00801B 00801C 008021 008023 008024 008026 008029 00802A 00802C 00802D 00802E 008033 008034 008035 008037 008038 00803B 00803D 00803E 00803F 008042 008043 008045 008046 008048 008049 00804C 00804D
UMC UM9008 NE2000-compatible ISA Card for PC 3Com Found in a 3Com PCI form factor 3C905 TX board Cisco Catalyst 5000 Ethernet switch Active Imaging Inc. Cisco Cisco 100Mbps interface Cisco Realtek (RTL 8029 == PCI NE2000) Cisco Acer Lan Cisco routers (2524 and 4500) Cisco Systems, Inc. 3620/3640 routers 3Com (1990 onwards) AMD PCNET PCI 3Com Hewlett-Packard Multitech Systems Inc Periphonics Corporation Antlow Computers, Ltd. Cactus Computer Inc. Compuadd Corporation Dlog NC-Systeme Jupiter Systems (older MX-600 series machines) Vosswinkel FU SMC (Standard Microsystem Corp.) Commodore IMS Corp. IMS failure analysis tester Thomas Conrad Corp. Seiko Systems Inc Wandel & Goltermann PFU Dayna Communications "Etherprint" product Bell Atlantic Kodiak Technology Cisco Newbridge Networks Corporation Integrated Business Networks Kalpana Network Products Corporation Microdyne Corporation Test Systems & Simulations Inc The Sage Group PLC Xylogics, Inc. Annex terminal servers Plexcom, Inc. Formation (?) SMT-Goupil Technology Works Ericsson Business Comm. Data Research & Applications APT Communications, Inc. Surigiken Co Ltd Synernetics Hyundai Electronics Force Computers Networld Inc Matsushita Electric Ind Co University of Toronto Compex, used by Commodore and DEC at least Nissin Electric Co Ltd Contec Co., Ltd. Cyclone Microsystems, Inc.
008051 008052 008057 00805A 00805B 00805C 00805F 008060 008062 008063 008064 008067 008069 00806A 00806B 00806C 00806D 00806E 00806F 008071 008072 008074 008079 00807B 00807C 00807D 008082 008086 008087 00808A 00808B 00808C 00808D 00808E 008090 008092 008093 008094 008096 008098 00809A 00809B 00809D 00809F 0080A1 0080A3 0080A6 0080A7 0080AD 0080AE 0080AF 0080B1 0080B2 0080B6 0080BA 0080C0 0080C2 0080C6 0080C7 0080C8 0080C9 0080CE
ADC Fibermux Network Professor Adsoft Ltd Tulip Computers International BV Condor Systems, Inc. Agilis(?) Compaq Computer Corporation Network Interface Corporation Interface Co. Richard Hirschmann Gmbh & Co Wyse Square D Company Computone Systems ERI (Empac Research Inc.) Schmid Telecommunication Cegelec Projects Ltd Century Systems Corp. Nippon Steel Corporation Onelan Ltd SAI Technology Microplex Systems Ltd Fisher Controls Microbus Designs Ltd Artel Communications Corp. FiberCom Equinox Systems Inc PEP Modular Computers Gmbh Computer Generation Inc. Okidata Summit (?) Dacoll Limited Frontier Software Development Westcove Technology BV Radstone Technology Microtek International Inc Japan Computer Industry, Inc. Xyron Corporation Sattcontrol AB HDS (Human Designed Systems) X terminals TDK Corporation Novus Networks Ltd Justsystem Corporation Datacraft Manufactur'g Pty Ltd Alcatel Business Systems Microtest Lantronix (see also 0800A3) Republic Technology Inc Measurex Corp CNet Technology Used by Telebit (among others) Hughes Network Systems Allumer Co., Ltd. Softcom A/S NET (Network Equipment Technologies) Themis corporation Specialix (Asia) Pte Ltd Penril Datability Networks IEEE 802.1 Committee Soho Xircom, Inc. D-Link (also Solectek Pocket Adapters, and LinkSys PCMCIA) Alberta Microelectronic Centre Broadcast Television Systems
0080D0 0080D3 0080D4 0080D6 0080D7 0080D8 0080DA 0080E0 0080E3 0080E7 0080EA 0080F0 0080F1 0080F3 0080F4 0080F5 0080F7 0080FB 0080FE 00A000 00A092 00A0D1 00A0D2 00A024 00A040 00A0C9 00A0CC 00AA00 00B0D0 00C000 00C001 00C002 00C003 00C004 00C005 00C006 00C007 00C008 00C009 00C00A 00C00B 00C00C 00C00D 00C00E 00C00F 00C011 00C012 00C013 00C014 00C015 00C016 00C017 00C018 00C01A 00C01B 00C01C 00C01D 00C01F 00C020 00C021
Computer Products International Shiva Appletalk-Ethernet interface Chase Limited Apple Mac Portable(?) Fantum Electronics Network Peripherals Bruel & Kjaer XTP Systems Inc Coral (?) Lynwood Scientific Dev Ltd The Fiber Company Kyushu Matsushita Electric Co Opus Sun Electronics Corp Telemechanique Electrique Quantel Ltd Zenith Communications Products BVM Limited Azure Technologies Inc Bay Networks Ethernet switch Intermate International [LAN printer interfaces] National Semiconductor [COMPAQ Docking Station] Allied Telesyn 3com Apple (PCI Mac) Intel (PRO100B cards) MacSense 100Base-TX Adapter for Mac Also seen in PCs (?) Intel Computer Products International Lanoptics Ltd Diatek Patient Managment Sercomm Corporation Globalnet Communications Japan Business Computer Co.Ltd Livingston Enterprises Inc Portmaster (OEMed by Cayman) Nippon Avionics Co Ltd Pinnacle Data Systems Inc Seco SRL KT Technology (s) Pte Inc Micro Craft Norcontrol A.S. ARK PC Technology, Inc. Advanced Logic Research Inc Psitech Inc QNX Software Systems Ltd. [also Quantum Software Systems Ltd] Interactive Computing Devices Netspan Corp Netrix Telematics Calabasas New Media Corp Electronic Theatre Controls Fluke Lanart Corp Corometrics Medical Systems Socket Communications Interlink Communications Ltd. Grand Junction Networks, Inc. S.E.R.C.E.L. Arco Electronic, Control Ltd. Netexpress
00C023 00C024 00C025 00C027 00C028 00C029 00C02A 00C02B 00C02C 00C02D 00C02E 00C02F 00C030 00C031 00C032 00C033 00C034 00C035 00C036 00C039 00C03B 00C03C 00C03D 00C03E 00C03F 00C040 00C041 00C042 00C043 00C044 00C045 00C046 00C047 00C048 00C049 00C04D 00C04E 00C04F 00C050 00C051 00C055 00C056 00C057 00C058 00C059 00C05B 00C05C 00C05D 00C05E 00C060 00C061 00C063 00C064 00C065 00C066 00C067 00C068 00C069 00C06A 00C06B 00C06C 00C06D 00C06F
Tutankhamon Electronics Eden Sistemas De Computacao SA Dataproducts Corporation Cipher Systems, Inc. Jasco Corporation Kabel Rheydt AG Ohkura Electric Co Gerloff Gesellschaft Fur Centrum Communications, Inc. Fuji Photo Film Co., Ltd. Netwiz Okuma Corp Integrated Engineering B. V. Design Research Systems, Inc. I-Cubed Limited Telebit Corporation Dale Computer Corporation Quintar Company Raytech Electronic Corp Silicon Systems Multiaccess Computing Corp Tower Tech S.R.L. Wiesemann & Theis Gmbh Fa. Gebr. Heller Gmbh Stores Automated Systems Inc ECCI Digital Transmission Systems Datalux Corp. Stratacom Emcom Corporation Isolation Systems Inc Kemitron Ltd Unimicro Systems Inc Bay Technical Associates US Robotics Total Control (tm) NETServer Card Mitec Ltd Comtrol Corporation Dell Toyo Denki Seizo K.K. Advanced Integration Research Modular Computing Technologies Somelec Myco Electronics Dataexpert Corp Nippondenso Corp Networks Northwest Inc Elonex PLC L&N Technologies Vari-Lite Inc ID Scandinavia A/S Solectek Corporation Morning Star Technologies Inc May be miswrite of 0003C6 General Datacomm Ind Inc Scope Communications Inc Docupoint, Inc. United Barcode Industries Philp Drake Electronics Ltd California Microwave Inc Zahner-Elektrik Gmbh & Co KG OSI Plus Corporation SVEC Computer Corp Boca Research, Inc. Komatsu Ltd
00C070 00C071 00C072 00C073 00C074 00C075 00C076 00C077 00C078 00C079 00C07A 00C07B 00C07D 00C07F 00C080 00C081 00C082 00C084 00C085 00C086 00C087 00C089 00C08A 00C08B 00C08C 00C08D 00C08E 00C08F 00C090 00C091 00C092 00C093 00C095 00C096 00C097 00C098 00C09B 00C09C 00C09D 00C09F 00C0A0 00C0A1 00C0A2 00C0A3 00C0A4 00C0A7 00C0A8 00C0A9 00C0AA 00C0AB 00C0AC 00C0AD 00C0AE 00C0B0 00C0B2 00C0B3 00C0B4 00C0B5 00C0B6 00C0B7 00C0B8 00C0B9 00C0BA
Sectra Secure-Transmission AB Areanex Communications, Inc. KNX Ltd Xedia Corporation Toyoda Automatic Loom Works Ltd Xante Corporation I-Data International A-S Daewoo Telecom Ltd Computer Systems Engineering Fonsys Co Ltd Priva BV Ascend Communications ISDN bridges/routers RISC Developments Ltd Nupon Computing Corp Netstar Inc Metrodata Ltd Moore Products Co Data Link Corp Ltd Canon The Lynk Corporation UUNET Technologies Inc Telindus Distribution Lauterbach Datentechnik Gmbh RISQ Modular Systems Inc Performance Technologies Inc Tronix Product Development Network Information Technology Matsushita Electric Works, Ltd. Praim S.R.L. Jabil Circuit, Inc. Mennen Medical Inc Alta Research Corp. Znyx (Network Appliance box); Jupiter Systems (MX-700 series) Tamura Corporation Archipel SA Chuntex Electronic Co., Ltd. Reliance Comm/Tec, R-Tec Systems Inc TOA Electronic Ltd Distributed Systems Int'l, Inc. Quanta Computer Inc Advance Micro Research, Inc. Tokyo Denshi Sekei Co Intermedium A/S Dual Enterprises Corporation Unigraf OY SEEL Ltd GVC Corporation Barron McCann Ltd Silicon Valley Computer Jupiter Technology Inc Gambit Computer Communications Computer Communication Systems Towercom Co Inc DBA PC House GCC Technologies,Inc. Norand Corporation Comstat Datacomm Corporation Myson Technology Inc Corporate Network Systems Inc Meridian Data Inc American Power Conversion Corp Fraser's Hill Ltd. Funk Software Inc Netvantage
00C0BB 00C0BD 00C0BE 00C0BF 00C0C0 00C0C1 00C0C2 00C0C3 00C0C4 00C0C5 00C0C6 00C0C8 00C0C9 00C0CA 00C0CB 00C0CD 00C0D0 00C0D1 00C0D2 00C0D4 00C0D5 00C0D6 00C0D9 00C0DB 00C0DC 00C0DE 00C0DF 00C0E1 00C0E2 00C0E3 00C0E4 00C0E5 00C0E6 00C0E7 00C0E8 00C0E9 00C0EA 00C0EC 00C0ED 00C0EE 00C0EF 00C0F0 00C0F1 00C0F2 00C0F3 00C0F4 00C0F5 00C0F6 00C0F7 00C0F8 00C0FA 00C0FB 00C0FC 00C0FD 00C0FF 00DD00 00DD01 00DD08 00E011 00E014 00E016 00E01E 00E029
Forval Creative Inc Inex Technologies, Inc. Alcatel - Sel Technology Concepts Ltd Shore Microsystems Inc Quad/Graphics Inc Infinite Networks Ltd. Acuson Computed Sonography Computer Operational SID Informatica Personal Media Corp Micro Byte Pty Ltd Bailey Controls Co Alfa, Inc. Control Technology Corporation Comelta S.A. Ratoc System Inc Comtree Technology Corporation (EFA also reported) Syntellect Inc Axon Networks Inc Quancom Electronic Gmbh J1 Systems, Inc. Quinte Network Confidentiality Equipment Inc IPC Corporation (Pte) Ltd EOS Technologies, Inc. ZComm Inc Kye Systems Corp Sonic Solutions Calcomp, Inc. Ositech Communications Inc Landis & Gyr Powers Inc GESPAC S.A. TXPORT Fiberdata AB Plexcom Inc Oak Solutions Ltd Array Technology Ltd. Dauphin Technology US Army Electronic Proving Ground Kyocera Corporation Abit Corporation Kingston Technology Corporation Shinko Electric Co Ltd Transition Engineering Inc Network Communications Corp Interlink System Co., Ltd. Metacomp Inc Celan Technology Inc. Engage Communication, Inc. About Computing Inc. Canary Communications Inc Advanced Technology Labs ASDG Incorporated Prosum Box Hill Systems Corporation Ungermann-Bass IBM RT Ungermann-Bass Ungermann-Bass Uniden Corporation Cisco Ethernet switch rapid-city (now a part of bay networks) Cisco Lightstream 1010 SMC EtherPower II 10/100
00E02C 00E034 00E039 00E04F 00E083 00E08F 00E098 00E0A3 00E0B0 00E0B8 00E0C5 00E0F7 00E0F9 00E0FE 020406 020701 020701 026060 026086 02608C 02AA3C 02CF1F 02E03B 02E6D3 080001 080002 080003 080005 080006 080007 080008 080009 08000A 08000B 08000D 08000E 08000F 080010 080011 080014 080017 08001A 08001B 08001E 08001F 080020 080022 080023 080025 080026 080027 080028 08002B 08002E 08002F 080030 080032 080036
AST - built into 5166M PC motherboard (win95 id's as Intel) Cisco Paradyne 7112 T1 DSU/CSU Cisco Jato Technologies, Inc. Cisco Systems Catalyst 2900 Linksys PCMCIA card Cisco Cisco Systems Catalyst 2900/5000 AMD PCNet in a Gateway 2000 BCOM Electronics Inc. Cisco Cisco Cisco BBN internal usage (not registered) Interlan [now Racal-InterLAN] DEC (UNIBUS or QBUS), Apollo, Cisco Racal-Datacom 3Com Satelcom MegaPac (UK) 3Com IBM PC; Imagen; Valid; Cisco; Macintosh Olivetti CMC Masscomp; Silicon Graphics; Prime EXL Prominet Corporation Gigabit Ethernet Switch BTI (Bus-Tech, Inc.) IBM Mainframes Computer Vision 3Com (formerly Bridge) ACC (Advanced Computer Communications) Symbolics Symbolics LISP machines Siemens Nixdorf PC clone Apple BBN (Bolt Beranek and Newman, Inc.) Hewlett-Packard Nestar Systems Unisys ICL (International Computers, Ltd.) NCR/AT&T SMC (Standard Microsystems Corp.) AT&T [misrepresentation of 800010?] Tektronix, Inc. Excelan BBN Butterfly, Masscomp, Silicon Graphics National Semiconductor Corp. (used to have Network System Corp., wrong NSC) Tiara? (used to have Data General) Data General Apollo Sharp Sun NBI (Nothing But Initials) Matsushita Denso CDC Norsk Data (Nord) PCS Computer Systems GmbH TI Explorer DEC Metaphor Prime Computer Prime 50-Series LHC300 CERN Tigan Intergraph CAE stations
Fuji Xerox Bull Spider Systems Torus Systems cadnetix Motorola VME bus processor modules DCA (Digital Comm. Assoc.) DSI (DAVID Systems, Inc.) ???? (maybe Xylogics, but they claim not to 080045 know this number) 080046 Sony 080047 Sequent 080048 Eurotherm Gauging Systems 080049 Univation 08004C Encore BICC [3com bought BICC, so may appear 08004E on 3com equipment as well] 080051 Experdata 080056 Stanford University 080057 Evans & Sutherland (?) 080058 ??? DECsystem-20 08005A IBM 080066 AGFA printers, phototypesetters etc. 080067 Comdesign 080068 Ridge 080069 Silicon Graphics 08006A ATTst (?) 08006E Excelan 080070 Mitsubishi 080074 Casio 080075 DDE (Danish Data Elektronik A/S) 080077 TSL (now Retix) 080079 Silicon Graphics 08007C Vitalink TransLAN III 080080 XIOS 080081 Crosfield Electronics 080083 Seiko Denshi 080086 Imagen/QMS 080087 Xyplex terminal servers 080088 McDATA Corporation 080089 Kinetics AppleTalk-Ethernet interface 08008B Pyramid 08008D XyVision XyVision machines 08008E Tandem / Solbourne Computer ? 08008F Chipcom Corp. 080090 Retix, Inc. Bridges 09006A AT&T 10005A IBM 100090 Hewlett-Packard Advisor products 1000D4 DEC Apple A/UX (modified addresses for 1000E0 licensing) LAA (Locally Administered Address) for 2E2E2E Meditech Systems 3Com dual function (V.34 modem + 3C0000 Ethernet) card 400003 Net Ware (?) 444553 Microsoft (Windows95 internal "adapters") 444649 DFI (Diamond Flower Industries) GTC (Not registered!) (This number is a 475443 multicast!) 484453 HDS ??? 484C00 Network Solutions 4854E8 winbond? Information Modes software modified 4C424C addresses (not registered?)
52544C Novell 2000 5254AB REALTEK (a Realtek 8029 based PCI Card) 565857 Aculab plc audio bridges AT&T [misrepresented as 080010? One 800010 source claims this is correct] CNET Technology Inc. (Probably an error, 80AD00 see instead 0080AD) AA0000 DEC obsolete AA0001 DEC obsolete AA0002 DEC obsolete DEC Global physical address for some DEC AA0003 machines DEC Local logical address for DECNET AA0004 systems Western Digital (may be reversed 00 00 C00000 C0?) EC1000 Enance Source Co., Ltd. PC clones(?)
Le passwords di defaults
Queste che seguono sono alcune password di default.
Manufacturer 3Com 3Com 3Com 3Com 3Com 3Com 3Com 3com 3Com 3Com 3Com 3Com 3Com 3Com 3Com 3Com 3Com 3Com 3Com 3com 3com 3com 3Com 3Com 3com 3Com 3Com 3com 3Com 3Com 3com 3Com 3Com 3COM 3com 3com 3com 3Com 3Com 3Com ACC Acc/Newbridge Acc/Newbridge adaptec Adaptec RAID adtran Adtran Adtran Aironet alcatel Alcatel Model Super Stack 2 Switch AccessBuilder 7000 BRI CoreBuilder 2500 Switch 3000/3300 Switch 3000/3300 Switch 3000/3300 Cable Managment System SQL Database (DOSCIC DHCP) NAC (Network Access Card) HiPer ARC Card CoreBuilder 6000 CoreBuilder 7000 SuperStack II Switch 2200 SuperStack II Switch 2700 SuperStack / CoreBuilder SuperStack / CoreBuilder SuperStack / CoreBuilder LinkSwitch and CellPlex LinkSwitch and CellPlex Superstack II 3300FX Switch 3000/3300 3comCellPlex7000 Switch 3000/3300 AirConnect Access Point Superstack II Dual Speed 500 OfficeConnect 5x1 SuperStack 3 Switch 3300XM Super Stack 2 Switch SuperStack II Switch 1100 SuperStack II Switch 1100 super stack 2 switch Office Connect Remote 812 Switch 3000/3300 OCR-812 OS Version 1.25 Any Any Login root manager manager admin security Password letmein manager manager admin security 3com none none tech tech synnet tech tech synnet 3com tech monitor comcomcom security PASSWORD manager manager security manager !root admin !root 0000 Password manager netman netman netman adaptec ADTRAN ADTRAN -
Win2000 & MS DOCSIS_APP adm v4.1.x of HA adm debug tech debug tech admin read write tech debug admin Admin tech monitor n/a security
at least 5.x Any any admin manager manager security manager root admin
root administrato NBX100 2.8 r Home Connect User estheralastr OfficeConnect 5x1 at least 5.x uey SuperStack II Switch 3300 manager Superstack Routers netman C