Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi N - Z > Reti di calcolatori > [LABORATORIO PRINI CASSIANO] Esame Marzo 06
Pages (7): « 1 [2] 3 4 5 6 » ... Last »   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
valery1
Paladina della giustiziA

User info:
Registered: Nov 2004
Posts: 339 (0.05 al dì)
Location:
Corso: Comunicazione Digitale
Anno: III, turno 1
Time Online: 1 Day, 10:32:28 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Vodoo ha messo un link a cui puoi trovare gli esercizi d'esempio, proprio in questo thread! altri non ce ne sono penso.....caso mai inventali! eheh

ma l'orario dell'esame non è uscito?! o almeno il giorno!!!!

__________________
۞_Rag Doll_۞

Last edited by valery1 on 05-03-2006 at 21:12

05-03-2006 20:40
Click Here to See the Profile for valery1 Click here to Send valery1 a Private Message Visit valery1's homepage! Find more posts by valery1 Add valery1 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
pinauz
.grande:maestro.

User info:
Registered: Nov 2004
Posts: 734 (0.10 al dì)
Location: a casa mai
Corso: NO: la nostra risposta al vostro calcio
Anno: !!!!!!!
Time Online: 3 Days, 17:43:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

x quanto mi riguarda la vedo grigia!! provo a postare 4 esempi che mi sono arrivati per le mani...fatemi sapere che ne pensate

Attachment: client_sever_udp.doc
This has been downloaded 62 time(s).

05-03-2006 22:39
Click Here to See the Profile for pinauz Click here to Send pinauz a Private Message Find more posts by pinauz Add pinauz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
pinauz
.grande:maestro.

User info:
Registered: Nov 2004
Posts: 734 (0.10 al dì)
Location: a casa mai
Corso: NO: la nostra risposta al vostro calcio
Anno: !!!!!!!
Time Online: 3 Days, 17:43:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

e questo

Attachment: client_server_tcp.doc
This has been downloaded 38 time(s).

05-03-2006 22:40
Click Here to See the Profile for pinauz Click here to Send pinauz a Private Message Find more posts by pinauz Add pinauz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Glucks
.illuminato.

User info:
Registered: May 2003
Posts: 220 (0.03 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 15:43:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

vi posto un esempio su cui ho studiato molto e sul quale ho imparato le funzioni per la programmazione. Una volta imparato bene questo esempio poi ho spaziato e aggiunto una serie di dialoghi client/server per vedere se avevo capito. Ve lo posto semplice, è quello che gira sui siti. Se lo copiate tale e quale in blocco note e lo compilate funziona.

Si tratta di un client che chiede in input una frase, la spedisce al server, il server la trasforma in maiuscolo con una semplice funzione (toUpperCase) e la rispedisce al client, che la visualizza.
L'esempio è fatto sia in TCP che in UDP, così vedete la stessa cosa fatta nei 2 metodi...


CLIENT UDP

import java.io.*;
import java.net.*;

class clientUDP
{
public static void main(String args[]) throws Exception
{
DatagramSocket client = null;
DatagramPacket pacchetto_send, pacchetto_recv;
InetAddress indirizzo;
String frase_client, frase_server;
byte[] buffer;

client = new DatagramSocket();

buffer = new byte[1024];

System.out.println("Inserisci la frase da modificare: ");
BufferedReader from_client = new BufferedReader(new InputStreamReader(System.in));
frase_client = from_client.readLine();

buffer = frase_client.getBytes();

indirizzo = InetAddress.getByName("localhost");
pacchetto_send = new DatagramPacket(buffer, buffer.length, indirizzo, 7000);
client.send(pacchetto_send);

pacchetto_recv = new DatagramPacket(buffer, buffer.length);
client.receive(pacchetto_recv);
frase_server = new String(pacchetto_recv.getData());
System.out.println("La frase modificata è: " + frase_server);
client.close();
}
}





SERVER UDP

import java.io.*;
import java.net.*;

class serverUDP
{
public static void main(String args[]) throws Exception
{
ThreadUDP t;
t = new ThreadUDP();
t.start();
}
}


class ThreadUDP extends Thread
{
DatagramSocket server;
DatagramPacket pacchetto_send, pacchetto_recv;
byte[] dati_send = new byte[1024];
byte[] dati_recv = new byte[1024];
String frase_client, frase_server;
InetAddress indirizzo;
int porta_client;

public void run()
{
try
{
while(true)
{
server = new DatagramSocket(7000);
pacchetto_recv = new DatagramPacket(dati_recv, dati_recv.length);
server.receive(pacchetto_recv);
frase_client = new String (pacchetto_recv.getData());
frase_server = frase_client.toUpperCase();
dati_send = frase_server.getBytes();
porta_client = pacchetto_recv.getPort();
indirizzo = pacchetto_recv.getAddress();
pacchetto_send = new DatagramPacket(dati_send, dati_send.length, indirizzo, porta_client);

server.send(pacchetto_send);

}
}
catch(IOException e) {}
}
}





CLIENT TCP


import java.io.*;
import java.net.*;

class clientTCP {
public static void main (String args[]) throws Exception {
String frase_client, frase_server;
Socket client = null;

client = new Socket("localhost",7000);
System.out.println("Inserisci la frase da modificare:");
BufferedReader from_client = new BufferedReader(new InputStreamReader(System.in));
DataOutputStream client_out = new DataOutputStream(client.getOutputStream());
frase_client = from_client.readLine();
client_out.writeBytes(frase_client + '\n');
BufferedReader from_server = new BufferedReader(new InputStreamReader(client.getInputStream()));
frase_server = from_server.readLine();
System.out.println("La stringa modificata e': " + frase_server);
client.close();
}
}





SERVER TCP


import java.io.*;
import java.net.*;

class serverTCP {
public static void main (String args[]) throws Exception {
ServerSocket server = null;
Socket client = null;
ThreadTCP t;

try
{
server = new ServerSocket(7000);
}
catch (IOException e){}
while(true)
{
client = server.accept();
t = new ThreadTCP(client);
t.start();
}
}
}

class ThreadTCP extends Thread {
Socket thread_client = null;

public ThreadTCP(Socket client)
{
this.thread_client = client;
}

public void run()
{
try
{
String frase_client, frase_server;
BufferedReader from_client = new BufferedReader(new InputStreamReader(thread_client.getInputStream()));
frase_client = from_client.readLine();
frase_server = frase_client.toUpperCase();
DataOutputStream server_out = new DataOutputStream(thread_client.getOutputStream());
server_out.writeBytes(frase_server + '\n');
}
catch (IOException e) {}
}
}

__________________
In un bagno in via Celoria c'è scritto: "Se entri con il sedere che prude, esci con il dito che puzza!!"

05-03-2006 23:25
Click Here to See the Profile for Glucks Click here to Send Glucks a Private Message Find more posts by Glucks Add Glucks to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
kaste81
.consigliere.

User info:
Registered: Oct 2002
Posts: 144 (0.02 al dì)
Location: milano NIGUARDA
Corso: comunicazione digitale
Anno: 3
Time Online: 4 Days, 21:20:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Grazie x gli esempi, sono effettivamente molto utili!!!

__________________
"Anche stanotte le nostre chitarre morderanno e a chi sta per fare rock io rendo onore............"
"And be a simple kind of man.
Be something you love and understand"
LONG LIVE ROCK 'N' ROLL!!!!!!!!!

06-03-2006 00:21
Click Here to See the Profile for kaste81 Click here to Send kaste81 a Private Message Find more posts by kaste81 Add kaste81 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Mattex185
.grande:maestro.

User info:
Registered: Sep 2004
Posts: 520 (0.07 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: Laureato
Time Online: 11 Days, 3:18:23 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

data e orari (apro altro solo x fare "pulizia" :))
http://www.dsy.it/forum/showthread....&threadid=24476

06-03-2006 08:36
Click Here to See the Profile for Mattex185 Click here to Send Mattex185 a Private Message Find more posts by Mattex185 Add Mattex185 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
pinauz
.grande:maestro.

User info:
Registered: Nov 2004
Posts: 734 (0.10 al dì)
Location: a casa mai
Corso: NO: la nostra risposta al vostro calcio
Anno: !!!!!!!
Time Online: 3 Days, 17:43:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

i programmi sono ottimi!!! "basta impararli a memoria"....l'esame consiste in una cosa simile vero? non bisogna gestire più richieste multithread o cose varie? cmq xkè udp chiude la connessione server e tcp no?

06-03-2006 15:37
Click Here to See the Profile for pinauz Click here to Send pinauz a Private Message Find more posts by pinauz Add pinauz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bruzzanboy
.::Fik!::.

User info:
Registered: Feb 2003
Posts: 389 (0.05 al dì)
Location: Milano_Bruzzancity Beach
Corso: Digital_Comunication!
Anno: Terzo uhuh!
Time Online: 2 Days, 4:30:14 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

a me cmq non vanno nessuno dei 4 programmi di vodoo...
cioè, 3 su 4 li compila e nesusno poi parte, è un problema del mio pc?

__________________
http://www.myspace.com/bruzzband
va che spacchiamo i culicchi!

06-03-2006 16:18
Click Here to See the Profile for Bruzzanboy Click here to Send Bruzzanboy a Private Message Visit Bruzzanboy's homepage! Find more posts by Bruzzanboy Add Bruzzanboy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bruzzanboy
.::Fik!::.

User info:
Registered: Feb 2003
Posts: 389 (0.05 al dì)
Location: Milano_Bruzzancity Beach
Corso: Digital_Comunication!
Anno: Terzo uhuh!
Time Online: 2 Days, 4:30:14 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

dice sempre Exception in thread "main" java.lang.noclassfounderror blablabla

__________________
http://www.myspace.com/bruzzband
va che spacchiamo i culicchi!

06-03-2006 16:20
Click Here to See the Profile for Bruzzanboy Click here to Send Bruzzanboy a Private Message Visit Bruzzanboy's homepage! Find more posts by Bruzzanboy Add Bruzzanboy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
pinauz
.grande:maestro.

User info:
Registered: Nov 2004
Posts: 734 (0.10 al dì)
Location: a casa mai
Corso: NO: la nostra risposta al vostro calcio
Anno: !!!!!!!
Time Online: 3 Days, 17:43:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

se intendi i 4 postati da glucks sembra strano a me vanno tutti e 4...ma tu come gestisci la cosa? io facci opartire il server da dos e il client da gel (o programmi simili come jcreator o robe varie) e funziona tutto alla perfezione.
da quello che hai scritto ti lancia l'eccezione evidentemente la connessione server si blocca prima che parte il client.
in quello che non ti compila che errore ti da?

06-03-2006 16:38
Click Here to See the Profile for pinauz Click here to Send pinauz a Private Message Find more posts by pinauz Add pinauz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bruzzanboy
.::Fik!::.

User info:
Registered: Feb 2003
Posts: 389 (0.05 al dì)
Location: Milano_Bruzzancity Beach
Corso: Digital_Comunication!
Anno: Terzo uhuh!
Time Online: 2 Days, 4:30:14 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

nono, sono riuscito a compilarli tutti e 4, cmq io li lancio tutti da dos, prima i server poi i client e tutti mi danno quel problema...
vabè oh, a sto punto me li imparo a memoria e spero che in laboratorio funzionino...

__________________
http://www.myspace.com/bruzzband
va che spacchiamo i culicchi!

06-03-2006 16:54
Click Here to See the Profile for Bruzzanboy Click here to Send Bruzzanboy a Private Message Visit Bruzzanboy's homepage! Find more posts by Bruzzanboy Add Bruzzanboy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Glucks
.illuminato.

User info:
Registered: May 2003
Posts: 220 (0.03 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 15:43:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

potrebbe essere perchè non hai chiamato il file con il nome della classe...

se la classe si chiama

class ClientTCP .........

il file da compilare si dovrà chiamare ClientTCP.java (con la maiuscola)

Quel problema me lo dava quando non trovava il file... o non l'avevo chiamato bene (attenzione perchè lo compila senza problemi, ma se ne va a male quando viene eseguito)

Spero sia questo il problema, giuro che a me vanno !!! Ed anche a qualcun altro che ha postato...

__________________
In un bagno in via Celoria c'è scritto: "Se entri con il sedere che prude, esci con il dito che puzza!!"

06-03-2006 17:00
Click Here to See the Profile for Glucks Click here to Send Glucks a Private Message Find more posts by Glucks Add Glucks to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bruzzanboy
.::Fik!::.

User info:
Registered: Feb 2003
Posts: 389 (0.05 al dì)
Location: Milano_Bruzzancity Beach
Corso: Digital_Comunication!
Anno: Terzo uhuh!
Time Online: 2 Days, 4:30:14 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

eh, purtroppo no, vabè pazienza... sono troppo depresso per perderci ancora tempo, java non fa certo bene alla salute

__________________
http://www.myspace.com/bruzzband
va che spacchiamo i culicchi!

06-03-2006 17:11
Click Here to See the Profile for Bruzzanboy Click here to Send Bruzzanboy a Private Message Visit Bruzzanboy's homepage! Find more posts by Bruzzanboy Add Bruzzanboy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
pinauz
.grande:maestro.

User info:
Registered: Nov 2004
Posts: 734 (0.10 al dì)
Location: a casa mai
Corso: NO: la nostra risposta al vostro calcio
Anno: !!!!!!!
Time Online: 3 Days, 17:43:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

scusa ma come fai a far partire 2 prog da dos contemporanemente?

06-03-2006 17:25
Click Here to See the Profile for pinauz Click here to Send pinauz a Private Message Find more posts by pinauz Add pinauz to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bruzzanboy
.::Fik!::.

User info:
Registered: Feb 2003
Posts: 389 (0.05 al dì)
Location: Milano_Bruzzancity Beach
Corso: Digital_Comunication!
Anno: Terzo uhuh!
Time Online: 2 Days, 4:30:14 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

uso il prompt dei comandi :D

__________________
http://www.myspace.com/bruzzband
va che spacchiamo i culicchi!

06-03-2006 17:52
Click Here to See the Profile for Bruzzanboy Click here to Send Bruzzanboy a Private Message Visit Bruzzanboy's homepage! Find more posts by Bruzzanboy Add Bruzzanboy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 19:59.    Post New Thread    Post A Reply
Pages (7): « 1 [2] 3 4 5 6 » ... Last »   Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.047 seconds (79.10% PHP - 20.90% MySQL) con 26 query.