Home| Progetto| Web| Faq| Acronimi | ||||
Argomenti Documenti pubblicabili:1120
Scripts:1282 Documenti non pubblicabili:162 Categorie tematiche:68 .Net |_C# |_Visual basic.net |_Asp.net Active Server Pages C++ Cascade Style Sheet JavaScript Mysql Php Xml Java |_Java 2 Micro Edition |_Java server pages |_Java Servlet Oracle |_PLSQL PostgreSQL Unix
Java...
Info:
Java conceived as an interpreted language
Unix...
Tip:
Rimuovere un file in Unix / Delete a file
PLSQL...
Script:
FOR recordset IN (select statment) LOOP
Java...
Tip:
Il parametro verbose
Shell scripting...
Script:
Passing parameters to shell script
A User Agent, like a web browser, uses HTTP to request a HTML document
Php Funzione mail()
In programming the danger of exploring the small details of coding is that you get obsessed with every line of code you write, thereby greatly reducing productivity.
In general, is not worth obsessing over code. On the other hand you should code with deliberation and intent. Steven Feurstein Oracle Magazine July /August 2004 A User Agent, like a web browser, uses HTTP to request a HTML document
|
Java
Home >Java > Client/Server connessione programma client ad un programma server
Compilare i due programmi con javac - deprecation myclient.java javac - deprecation myserver.java Perche il metoro readLine() in java.io.DataInputStream è stato "deprecated". Pertanto la compilazione genera un warning non rilevante comunque ai fini dell'esempio. In una finestra dos lanciare myserver (java myserver) in un'altra finestra dos lanciare myclient(java my client) Se la connessione ha luogo un messaggio di conferma viene visualizzato nella finestra dell'applicazione myserver identificano il nome utente trasmesso dalla\'applicazione myclient. In fase di compilazione può risultare un warning, che non impedisce comunque la dimostrazione del funzionamento dei due programmi. Mentre l'applicazione myserver è avviata in un altra finestra dos è possibile verificare l'attivtà sulla porta 1111 con il comando windows netstat //************************************************************************** //file myserver.java import java.io.*; import sun.net.*; class myserver extends NetworkServer { public static void main(String args[]) { System.out.println("Aspettando per utenti"); try { // attiva il servizio sulla porta 1111 (new myserver()).startServer(1111); } catch (IOException e) { System.out.println("Impossibile avviare server"); } } public void serviceRequest() { DataInputStream net_input = new DataInputStream(clientInput); String nomeutente; System.out.println("Connessione al client....."); clientOutput.println("login"); clientOutput.flush(); try { if ((nomeutente = net_input.readLine()) == null) { System.out.println("ReadLine ha restituito nullo"); return; } } catch (IOException e) { System.out.println("Errore nella lettura della riga"); return; } System.out.println("Nome utente " + nomeutente); clientOutput.println("Login eseguito con successo"); clientOutput.flush(); System.out.println(nomeutente + " disconnesso "); } } //************************************************************************** //file myclient.java import java.io.*; import sun.net.*; class myclient { static NetworkClient net; static DataInputStream net_input; static PrintStream net_output; public static void main(String arg[]) { System.out.println("Connessione ..."); System.out.flush(); try { // definire il nome del vostro computer al quale ci si vuole connettere e la porta net = new NetworkClient("localhost",1111); } catch (IOException e) { System.out.println("Errore nella creazione del NetworkClient"); return; } if (net.serverIsOpen()) System.out.println("ok..."); else { System.out.println("Errore"); System.out.println("Non è possibile stabilire la connessione all\'host"); return; } net_input = new DataInputStream(net.serverInput); net_output = net.serverOutput; System.out.println("In attesa del prompt di login"); System.out.println("Il server comunica: " + get_net_input()); System.out.println("Loggin on...."); // Invia al programma server il nome utente net_output.println("Marco "); System.out.println("In attesa di risposta...."); System.out.println("Il server comunica: " + get_net_input()); System.out.println("Disconnessione ..."); System.out.flush(); close_server(); System.out.println("Eseguito"); } static String get_net_input() { String a; try { a = net_input.readLine(); } catch (IOException e) { a =""; } return a; } static void close_server() { try { net.closeServer(); } catch(Exception e) { System.out.println("Impossibile chiudere il server"); } } } Warning: include(ads/text468x15.html): failed to open stream: No such file or directory in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Warning: include(): Failed opening 'ads/text468x15.html' for inclusion (include_path='.;C:\php\pear') in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Tutorial ![]() ![]() ![]() ![]() ![]() ![]() ![]() Script ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Comandi ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Cerca
Java...
Info:
Java conceived as an interpreted language
Anger is creative, depression is useless.
Dyson, Freeman J. Anger is creative, depression is useless.
Dyson, Freeman J.
Java...
Info:
Tipologie comuni di metodi specializzati
Java...
Definizioni:
Eccezioni
Oracle...
Definizioni:
Transazione
Shell scripting...
Script:
Pulire i file provenienti da ambieti dos/ windoes da caratteri sporchi
fishScript.Com is accessible by Mobile access technology
as mobile phones, Palm and Pocket PC .
Nicoleta e Marco Magnani tutorial, examples, courses, esempi, corsi, esercizi, appunti vari Dottoressa Nicoleta Dragu Formatrice Docente Insegnante Mediatrice Culturale Dott. Marco Magnani Universita La Sapienza Roma Master Computer Science Hunter College New York , Data Base Administrator DBA oracle System architect |