Skip to content

Commit

Permalink
Merge pull request #25 from rchakra3/ConsistentHashing
Browse files Browse the repository at this point in the history
LB-ServerThread
  • Loading branch information
vinay92 committed Apr 19, 2015
2 parents 98d6769 + 6efb14d commit 48396a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
13 changes: 1 addition & 12 deletions src/network/LBClientServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,11 @@ public class LBClientServer {
public LBClientServer(){
try {
LBSocket = new ServerSocket(serverPort);
this.startListening();
new Thread(new ServerThread(LBSocket)).start();
} catch (IOException e) {
System.out.println("Error while trying to connect with the client ");
e.printStackTrace();
}
}

private void startListening(){
while(true){
try {
(new Thread(new ClientConnectionHandler(LBSocket.accept()))).start();
} catch (IOException e) {
System.out.println("Error in the accept block ");
e.printStackTrace();
}
}
}

}
28 changes: 28 additions & 0 deletions src/network/ServerThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package network;

import java.io.IOException;
import java.net.ServerSocket;

import edu.tomr.loadbalancer.ClientConnectionHandler;

public class ServerThread implements Runnable {
private ServerSocket LBSocket = null;

public ServerThread(ServerSocket newSocket){
this.LBSocket = newSocket;
}

@Override
public void run() {
while(true){
try {
(new Thread(new ClientConnectionHandler(LBSocket.accept()))).start();
} catch (IOException e) {
System.out.println("Error in the accept block ");
e.printStackTrace();
}
}

}

}

0 comments on commit 48396a1

Please sign in to comment.