Aspettiamo fiduciosi l'aiuto di floyd !!!
![]()
![]()
![]()
![]()
Ho cannato faccina.. sorry...
:gren: :gren: :gren:
up! :adhone:
My SO:WinXP pro/Linux Debian/Gentoo 2006.0
scrivi il codice con il quale apri il thread
codice:public synchronized void attivasocket() { int port=3000; // porta di ascolto try { serverSocket=new ServerSocket(port); LabelStatoClient = new JLabel("Server attivo sulla porta 3000"); } catch (IOException e) { System.err.println("Eccezione : impossibile creare socket"); } while(true) { Socket ClientSocket = null; try { ClientSocket = serverSocket.accept(); } catch (IOException inetException) { System.err.println("ERRORE: Client non accettato: porta 4475, " + inetException.getMessage()); continue; } new ServerThread(ClientSocket); } }
My SO:WinXP pro/Linux Debian/Gentoo 2006.0
prova a eliminare synchronized
c'č una cosa bruttina, tu crei un thread con ClientSocket, poi immagino che il ciclo torni a definire ClientSocket null, il thread a quel punto si trova un oggetto che punta a null
ho provato a fare una cosa brutale: ho eliminato sia synchronized che Socket ClientSocket = null per vedere cosa accadeva, ma ho lo stesso problema.
Non é che avendo definito thread e interfaccia grafica su due classi diverse, ogni volta che viene attivato un thread viene eseguita la classe del thread e quella dell'interfaccia viene "scartata"?
My SO:WinXP pro/Linux Debian/Gentoo 2006.0
mandami le classi ti do la mail privatamente
mandato...
My SO:WinXP pro/Linux Debian/Gentoo 2006.0
risolto :adhone:
non puoi chiamare accept() nella stessa classe del jframe, blocca il tutto, io l'ho messo nel thread, ho anche lanciato il thread al suo esterno dalla classe che lo invoca
:sexpulp: :sexpulp: :sexpulp: :sexpulp: :sexpulp:codice:class ServerThread extends Thread {//implements Runnable Socket ClientSocket; ServerSocket server; Thread t; private String [] verificaSettori = new String [60]; ServerThread(ServerSocket serverSocket) { server = serverSocket; } public void run() { try { ClientSocket = server.accept(); } catch(IOException ioex) { ioex.printStackTrace(); } ... public void attivasocket() { int port=3000; // porta di ascolto try { serverSocket=new ServerSocket(port); LabelStatoClient = new JLabel("Server attivo sulla porta 3000"); } catch (IOException e) { System.err.println("Eccezione : impossibile creare socket"); } ServerThread t = new ServerThread(serverSocket); t.start(); }