Ciao, ho creato il client e il server che devono scambiarsi come informazioni un intero e un array di stringhe tramite l'I/O stream ma non mi carica nulla e non mi genera nessun errore, il socket viene accettato.
Posto il codice:
CLIENT:
ObjectInputStream in = null;
ObjectOutputStream outStream = null;
try{
in = new ObjectInputStream (socket.getInputStream());
outStream = new ObjectOutputStream (socket.getOutputStream());
outStream.writeInt(numOperazione);
outStream.writeObject(parametri);
risultati = in.readObject();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("Object Not Found!!");
}finally {
System.out.println("Closing...");
in.close();
outStream.close();
socket.close();
SERVER:
try {
int operazione =in.readInt();
String []parametro = (String[])in.readObject();
this.risultato= OperazioniDaEffettuare.getOperazione(operazione, parametro);
System.out.println("Echoing: operazione "+ operazione+", pararemtro: ");
for (int i=0; i<parametro.length; i++)System.out.print(parametro[i]+" ");
outStream.writeObject(risultato);
}catch (IOException e){
System.err.println("IO Exception");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("Object Not Found!!");
}finally {
try{
System.out.println("Closing...");
socket.close();
}catch (IOException e){
System.err.println("Socket not closed!");
}
Grazie

Rispondi quotando