Skip to content
Snippets Groups Projects
Commit e5cff56c authored by brutzman's avatar brutzman
Browse files

Merge origin/master

parents 2a91a51c 72c87ee1
No related branches found
No related tags found
No related merge requests found
File added
...@@ -76,11 +76,12 @@ public class BoronClient { ...@@ -76,11 +76,12 @@ public class BoronClient {
// connections. // connections.
Socket socket = new Socket(LOCALHOST, 2317); Socket socket = new Socket(LOCALHOST, 2317);
// Sends messages back to server
OutputStream os = socket.getOutputStream(); OutputStream os = socket.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os); OutputStreamWriter osw = new OutputStreamWriter(os);
BufferedWriter bw = new BufferedWriter(osw); BufferedWriter bw = new BufferedWriter(osw);
// Now hook everything up (i.e. set up the streams), Java style: // Messages from server
InputStream is = socket.getInputStream(); InputStream is = socket.getInputStream();
InputStreamReader isr = new InputStreamReader(is); InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr); BufferedReader br = new BufferedReader(isr);
...@@ -92,12 +93,11 @@ public class BoronClient { ...@@ -92,12 +93,11 @@ public class BoronClient {
bw.flush(); bw.flush();
// Read a single line written by the server. We'd do things a bit differently if there were many // Reads line from the server
//lines to be read from the server instead of one only.
String serverMessage = br.readLine(); String serverMessage = br.readLine();
System.out.println(serverMessage); System.out.println(serverMessage);
} // end while(true) }
} catch (IOException e) { } catch (IOException e) {
System.err.println("Problem with BoronClient networking:"); // describe what is happening System.err.println("Problem with BoronClient networking:"); // describe what is happening
System.err.println("Error: " + e); System.err.println("Error: " + e);
......
...@@ -16,8 +16,6 @@ public class BoronServer { ...@@ -16,8 +16,6 @@ public class BoronServer {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
// ServerSocket waits for a connection from a client. Notice that it is outside the loop; ServerSocket
// needs to be made only once.
System.out.println("BoronServer has started..."); // it helps debugging to put this on console first System.out.println("BoronServer has started..."); // it helps debugging to put this on console first
ServerSocket serverSocket = new ServerSocket(2317); ServerSocket serverSocket = new ServerSocket(2317);
...@@ -27,7 +25,6 @@ public class BoronServer { ...@@ -27,7 +25,6 @@ public class BoronServer {
int localPort, remotePort; int localPort, remotePort;
// Server is up and waiting (i.e. "blocked" or paused) Loop, infinitely, waiting for client connections. // Server is up and waiting (i.e. "blocked" or paused) Loop, infinitely, waiting for client connections.
// Stop the program somewhere else.
while (true) { while (true) {
// block until connected to a client // block until connected to a client
...@@ -37,6 +34,8 @@ public class BoronServer { ...@@ -37,6 +34,8 @@ public class BoronServer {
os = clientConnection.getOutputStream(); os = clientConnection.getOutputStream();
ps = new PrintStream(os); ps = new PrintStream(os);
// Messages from the client
InputStream is = clientConnection.getInputStream(); InputStream is = clientConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is); InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr); BufferedReader br = new BufferedReader(isr);
...@@ -44,6 +43,8 @@ public class BoronServer { ...@@ -44,6 +43,8 @@ public class BoronServer {
System.out.println("We received a message from a client..."); System.out.println("We received a message from a client...");
System.out.println("Client: " + receivedInput); System.out.println("Client: " + receivedInput);
//Message pushed to client
ps.println("Server: Acknowleged, message received"); // this gets sent back to client! ps.println("Server: Acknowleged, message received"); // this gets sent back to client!
// Print some information locally about the Socket connection. // Print some information locally about the Socket connection.
...@@ -71,4 +72,4 @@ public class BoronServer { ...@@ -71,4 +72,4 @@ public class BoronServer {
} }
} }
} }
} }
\ No newline at end of file
assignments/src/MV3500Cohort2019JulySeptember/homework2/McCann Output.PNG

16.2 KiB

...@@ -42,8 +42,8 @@ public class McCannServer { ...@@ -42,8 +42,8 @@ public class McCannServer {
ps = new PrintStream(os); ps = new PrintStream(os);
Scanner keyboard = new Scanner(System.in); Scanner keyboard = new Scanner(System.in);
ps.println("What is your name?"); // this gets sent back to client! ps.println("What is your name?"); // this gets sent back to client!
String message = keyboard.nextLine(); //String message = keyboard.nextLine();
ps.println(message); // ps.println(message);
// Print some information locally about the Socket connection. // Print some information locally about the Socket connection.
// This includes the port and IP numbers on both sides (the socket pair). // This includes the port and IP numbers on both sides (the socket pair).
......
assignments/src/MV3500Cohort2019JulySeptember/homework2/McCann_ServerOutput.PNG

26.3 KiB

assignments/src/MV3500Cohort2019JulySeptember/homework2/McCann_WireShark_output.PNG

64.9 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment