Skip to content

Commit

Permalink
reorg threading
Browse files Browse the repository at this point in the history
  • Loading branch information
RScicomp committed Jan 31, 2020
1 parent 8e6e3eb commit 03646ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sketch_code_COMP_535/src/main/java/socs/network/node/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ private void processStart() {
System.out.println(link);
if(link != null){
System.out.println(link);
ServerHandler handler = new ServerHandler(link);
handler.run();
try{
Socket client = new Socket(link.router2.processIPAddress,link.router2.processPortNumber);
System.out.println("Just connected to" + client.getRemoteSocketAddress());
}catch(Exception e){
System.out.println("Failed");
}
}
//use our port number to send
//Socket client = new Socket("Sender", rd.processPortNumber);
Expand Down Expand Up @@ -141,6 +145,11 @@ public void terminal() {
try {
InputStreamReader isReader = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isReader);
//thread server listening to incoming connections.
Runnable handler = new ServerHandler(rd);
//handle incoming connection requests
Thread t1 = new Thread(handler);

System.out.print(">> ");
String command = br.readLine();
while (true) {
Expand Down Expand Up @@ -172,6 +181,7 @@ public void terminal() {
System.out.print(">> ");
command = br.readLine();
}
t1.start();
isReader.close();
br.close();
} catch (Exception e) {
Expand Down
Binary file not shown.

0 comments on commit 03646ea

Please sign in to comment.