Ciao
ho un problema con il seguente codice:
Codice del Server
codice:
Socket canale = null; ServerSocket server = null;
ExecutorService executor = Executors.newFixedThreadPool(50);
try {
server = new ServerSocket(40000);
while (true) {
canale=server.accept();
executor.execute(new EchoThread(canale));
}
} catch (IOException e) {
System.err.println("");
}finally{
try {
canale.close();
} catch (IOException e) {
System.err.println("Impossibile chiudere la socket");
}
}
Codice di EchoThread:
codice:
public class EchoThread implements Runnable {
Socket socket;
public EchoThread(Socket s) {
socket=s;
}
public void run(){
InputStream is;
try {
is = socket.getInputStream();
Richiesta richiesta = new Richiesta(is);
//ALTRE OPERAZIONI
}
}
Codice di Richiesta:
codice:
public class Richiesta {
public Richiesta(InputStream is){
// OPERAZIONI SULL' InputStram
}
}
Utilizzo il programma putty per simulare il client e dovrei inserire più richieste del tipo:
GET /aggiungiUtente?idUtente=mario HTTP/1.0
user-agent: Mozilla 5.0
host: localhost:6000
content-type: text/html
<rigaVuota>
La prima richiesta inserita con il GET, tutto funziona. Se subito dopo inserisco un'altra richiesta non esegue più il codice EchoThread e Richieste. Come se si bloccasse. come devo fare?
grazie tante