Ahoj mam udelat server ktery vysila a prijima na nejakem portu a zvladne zpracovavat vic klientu paraelne.Pokud budu zpracovavat jen jednoho klienta tak je vsechno v poradku ale testovaci klient mi pak vypise ze nezpracovavam data paraelne.Nevite nekde co s tim? Tady je kod:
class Server {
private static int port = 3999;
public static void main(int sPort) throws IOException, InterruptedException {
try {
port = sPort;
} catch (Exception e) {
System.out.println("Chyba pri nacitani portu");
}
//test zda se nacetl spravny port
if (port < 3000 || port > 3999) {
System.out.println("Zvolili jste spatny port, zvolte port z intervalu 3000-3999 vcetne");
System.out.println("Vas port byl: " + port);
System.exit(1);
}
System.out.println("SERVER JE SPUSTENY NA PORTU: " + port);
ServerSocket serverSocket = new ServerSocket(port);
Socket klientSocket = null;
while (true) {
klientSocket = serverSocket.accept();
Pripojeni connection = new Pripojeni(klientSocket);
Thread vlakno = new Thread(connection);
vlakno.start();
}
}
/**
* Trida umoznuje spusteni vice vlaken
*/
public static class Pripojeni implements Runnable {
private static PrintStream out = null;
private static BufferedReader in = null;
private Socket klientSocket = null;
public Pripojeni(Socket socket) {
this.klientSocket = socket; //vytvoreni objektu
}
public void run() {
try {
in = new BufferedReader(new InputStreamReader(klientSocket.getInputStream()), 2001000);
out = new PrintStream(klientSocket.getOutputStream(), true);
.....