Socket and multithreading problem (flow control)
This code is heavily influenced by the KKMultiServerThread. I am having problems controlling the thread flow.
login =new MultiServerThreadLogin(serverSocket.accept(), serverSocket);
login.start();
while(true){
System.out.println(login.getAuthen());
while(login.getAuthen()){
System.out.println("doing hello");
hello =new KKMultiServerThread(serverSocket.accept(), serverSocket);
hello.start();
if(hello.getFlag())
break;
}
}
here, you can see that i am trying to start a thread to login the user and then recieve files from the cilent. When my GUI runs, there is no problem whatsoever that is for the 1st time, however when i try running the 2nd time, the code as u can see, doesnt allow that... so is there anyway to break away from the inner loop?
[1197 byte] By [
Zsefva] at [2007-11-27 5:03:44]

# 2
hey thanks for replying... i'm sorry but in a rush here...
this snippet resides in the server. There are 2 classes, namely MultiServerLoginThread and KKMultiServerThread, both extends Thread.
The function of the MultiServerLoginThread is to read in bytes of Secretkey, username(encrypted) and password(encrypted). This should only take place once.
The function of theother thread, KKMultiServerThread is to read in the file name to be transferred and the contents. This is based on the KKMultiServerThread which can be found somewhere in this forum... i hope...
The KKMultiServerThread is started over and over because the client is sending multiple files. Hence the while loop. However after sending the last file, it should go to the MultiServerLoginThread....
One thing i don't really get it is that if i were to do this(put the creation of the login thread within the while loop):
while(true){
System.out.println(login.getAuthen());
login = new MultiServerThreadLogin(serverSocket.accept(), serverSocket);
login.start();
while(login.getAuthen()){
System.out.println("doing hello");
hello = new KKMultiServerThread(serverSocket.accept(), serverSocket);
hello.start();
if(hello.getFlag())
break;
}
}
The GUI totally hangs.
More explanation...
hello.getFlag() returns the flag when the client has finished sending all the files
login.getAuthen() returns whether the user has successfully logged in with correct creditials
Zsefva at 2007-7-12 10:21:51 >
