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): « First ... « 3 4 5 6 [7]   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
ilcizzy
.amico.

User info:
Registered: Nov 2003
Posts: 38 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 0:01:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
aiuto per client per favor

Salve a tutti. Premetto che è solo 2 giorni che mi sbatto con sti client.
Se qlc mi aiutasse con questo client gli ne sarei grato.
Innanzi tutto il server è questo:
---------------------------------------------------------------------------
import java.net.*;
import java.io.*;

// Test d'esame: scrivere un client compatibile con questo server.
// Lanciare il server connettendosi alla macchina "hal" del Silab.

class Ser {

public static void main (String args[]) {
ServerSocket welcomeSocket = (ServerSocket)null;
Socket serviceSocket = (Socket)null;

try {
welcomeSocket = new ServerSocket(10000);
while (true) {
serviceSocket = welcomeSocket.accept();
TeacherThread serviceThread =
new TeacherThread(serviceSocket);
serviceThread.start();
}
} catch(Exception e) { e.printStackTrace(); }
}
}

class TeacherThread extends Thread {
private Socket sock;

public TeacherThread(Socket sock) {
this.sock = sock;
}

public void run() {
try{

BufferedReader read = new BufferedReader(new InputStreamReader(sock.getInputStream()));
DataOutputStream rite =new DataOutputStream(sock.getOutputStream());

rite.writeBytes("Benvenuta/o al test d'esame.\n");

System.out.println("ho ricevuto questo");
String recv = read.readLine();
System.out.println(recv);

if (recv.equals("Ci provo..."))
{
rite.writeBytes("Test riuscito: potete andare.\n");
}
else
{
rite.writeBytes("Test non riuscito: riprovare.\n");
}

sock.close();
} catch(Exception e) { e.printStackTrace(); }
}
}

--------------------------------------------------------------------------------

il client che ho scritto e che ovviamente non funge è questo:

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

class Cli {
public static void main (String args[]) throws Exception {

String frase="Ci provo...";
//Creo una socket client con ip 'localhost' e porta '10000'
Socket client = null;
client = new Socket("localhost",10000);

try
{
BufferedReader from_server = new BufferedReader(new InputStreamReader(client.getInputStream()));
DataOutputStream client_out = new DataOutputStream(client.getOutputStream());

//ricevo il mess di benvenuto
String rcvMsg1 = from_server.readLine();
System.out.println(rcvMsg1);

//mando la frease
client_out.writeBytes(frase);


//ricevo la risp
String rcvMsg2 = from_server.readLine();
System.out.println(rcvMsg2);


//chiudo il client
client.close();
}

catch(IOException e)
{

System.out.println("Errore");
System.exit(-1);
}
}
}
---------------------------------------------------------------------------------------


Non capisco perche non vada.Grazie ciao

__________________
Un utente UNIX che fa sesso:
unzip strip touch finger mount fsck more yes umount sleep

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

User info:
Registered: Jan 2004
Posts: 1009 (0.13 al dì)
Location: Pisa
Corso: com. dig.
Anno: dottore :)
Time Online: 6 Days, 23:28:00: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ho già dato l'esame ma gli ho dato un'occhiata in volata..

code:
String frase="Ci provo..."; ..... client_out.writeBytes(frase);

Mi sembra manchi il solito carattere "\n" alla stringa sopra (oppure inserendolo dopo l'argomento "frase" passato a writeBytes). Almeno,se l'errore è che una volta ricevuto il benvenuto e ha mandato la frase si blocca tutto penso sia questo :)
Altrimenti dovrei guardarci a fondo cosa che non ho tempo di fare :)
Ciauz

__________________
GET DROPBOX
# il grado di lentezza è direttamente proporzionale all'intensità della memoria;il grado di velocità è direttamente proporzionale all'intensità dell'oblio (Kundera) #
BLOG: Byte Strike
ChRiS :ciao:

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

User info:
Registered: Nov 2003
Posts: 49 (0.01 al dì)
Location: milano
Corso: comunicazione digitale
Anno: 2
Time Online: 1 Day, 11:16:58 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

outClient.writeBytes(frase+'\n');l

16-06-2006 21:11
Click Here to See the Profile for cavals Click here to Send cavals a Private Message Find more posts by cavals Add cavals to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ilcizzy
.amico.

User info:
Registered: Nov 2003
Posts: 38 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 0:01:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Voodoo

Mi sembra manchi il solito carattere "\n" alla stringa sopra (oppure inserendolo dopo l'argomento "frase" passato a writeBytes). Almeno,se l'errore è che una volta ricevuto il benvenuto e ha mandato la frase si blocca tutto penso sia questo :)
Altrimenti dovrei guardarci a fondo cosa che non ho tempo di fare :)
Ciauz


in effetti era proprio cosi.
grazie 1000

__________________
Un utente UNIX che fa sesso:
unzip strip touch finger mount fsck more yes umount sleep

17-06-2006 07:43
Click Here to See the Profile for ilcizzy Click here to Send ilcizzy a Private Message Find more posts by ilcizzy Add ilcizzy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
~paolo~
Il Barbie ;)

User info:
Registered: Mar 2003
Posts: 319 (0.04 al dì)
Location: Pozzuolo M. (MI)
Corso:
Anno: Dott. ComDig
Time Online: 3 Days, 22:24:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ciao, sinceramente non ho capito cosa si intenda per

// Lanciare il server connettendosi alla macchina "hal" del Silab.


è solo per dire di lanciare il server e client in locale oppure connettersi alla macchina "hal" in qualche modo e poi eseguire il server da lì?

Paolo

__________________
msn: paolo198328@hotmail.com


21-06-2006 10:47
Click Here to See the Profile for ~paolo~ Click here to Send ~paolo~ a Private Message Find more posts by ~paolo~ Add ~paolo~ to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
~paolo~
Il Barbie ;)

User info:
Registered: Mar 2003
Posts: 319 (0.04 al dì)
Location: Pozzuolo M. (MI)
Corso:
Anno: Dott. ComDig
Time Online: 3 Days, 22:24:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by ~paolo~
Ciao, sinceramente non ho capito cosa si intenda per



è solo per dire di lanciare il server e client in locale oppure connettersi alla macchina "hal" in qualche modo e poi eseguire il server da lì?

Paolo


indirizzo e porta del server "hal" venivano forniti ? in caso contrario come si potevano ricavare?

__________________
msn: paolo198328@hotmail.com


21-06-2006 12:21
Click Here to See the Profile for ~paolo~ Click here to Send ~paolo~ a Private Message Find more posts by ~paolo~ Add ~paolo~ to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 17:54.    Post New Thread    Post A Reply
Pages (7): « First ... « 3 4 5 6 [7]   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.057 seconds (70.79% PHP - 29.21% MySQL) con 23 query.