Skip to content

Commit

Permalink
theading test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
RScicomp committed Jan 28, 2020
1 parent 93ae001 commit 8d6bead
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
33 changes: 30 additions & 3 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 @@ -3,10 +3,15 @@
import socs.network.util.Configuration;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.ServerSocket;
import java.net.UnknownHostException;

public class Router {

Expand Down Expand Up @@ -94,18 +99,40 @@ private void processStart() {
server = new ServerSocket(link.router1.processPortNumber);

while (true) {
Socket s = null;
/**
* create a new {@link SocketServer} object for each connection
* this will allow multiple client connections
*/

/*
Thread t1 = new Thread(new RunnableDemo().new RunnableImpl());
t1.start();
Socket server = new SocketServer(server.accept());
System.out.println("Just connected to " + server.getRemoteSocketAddress());
DataInputStream in = new DataInputStream(server.getInputStream());
System.out.println(in.readUTF());
if (in.readUTF().equals("HELLO")){
break;
}*/
try{
s = server.accept();
System.out.println("A new client is connected : " + s);

// obtaining input and out streams
DataInputStream dis = new DataInputStream(s.getInputStream());
//Recieve HELLO
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
//Send HELLO
System.out.println("Assigning new thread for this client");
// create a new thread object
serverHandler t = new serverHandler(link);
// Invoking the start() method
t.run();
}
catch (Exception e){
s.close();
e.printStackTrace();
}
}
} catch (IOException ex) {
System.out.println("Unable to start server.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
socs/network/message/LSA.class
socs/network/node/Link.class
socs/network/node/RouterStatus.class
socs/network/node/serverHandler.class
socs/network/Main.class
socs/network/message/SOSPFPacket.class
socs/network/node/LinkStateDatabase.class
socs/network/message/LinkDescription.class
socs/network/node/RouterDescription.class
socs/network/node/Router.class
socs/network/util/Configuration.class
socs/network/message/LSA.class
socs/network/node/Link.class
socs/network/node/RouterStatus.class

0 comments on commit 8d6bead

Please sign in to comment.