Skip to content
Snippets Groups Projects
Commit 1db8a3fe authored by Peter's avatar Peter
Browse files

Finished assignment, pending docs

parent b311e7df
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import java.io.InputStream; ...@@ -12,6 +12,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.net.Socket; import java.net.Socket;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
...@@ -32,6 +33,7 @@ public class SeversonAssignment2_Client { ...@@ -32,6 +33,7 @@ public class SeversonAssignment2_Client {
String message = "Waiting for Client Confirmation"; String message = "Waiting for Client Confirmation";
int confirm = JOptionPane.showConfirmDialog(null, message); int confirm = JOptionPane.showConfirmDialog(null, message);
int count = 0;
if (confirm == JOptionPane.YES_OPTION) { if (confirm == JOptionPane.YES_OPTION) {
...@@ -39,7 +41,8 @@ public class SeversonAssignment2_Client { ...@@ -39,7 +41,8 @@ public class SeversonAssignment2_Client {
System.out.println("TcpClient creating socket..."); System.out.println("TcpClient creating socket...");
Socket socket = new Socket(LOCALHOST, 2317); // locohost? Socket socket = new Socket(LOCALHOST, 2317);
count++;
InputStream is = socket.getInputStream(); InputStream is = socket.getInputStream();
InputStreamReader isr = new InputStreamReader(is); InputStreamReader isr = new InputStreamReader(is);
...@@ -47,14 +50,25 @@ public class SeversonAssignment2_Client { ...@@ -47,14 +50,25 @@ public class SeversonAssignment2_Client {
String serverMessage = br.readLine(); String serverMessage = br.readLine();
System.out.println("=================================================="); System.out.println("==================================================");
System.out.println("Now we're talking!"); System.out.println("Successful Connection | Number: " + count);
System.out.println("The message the server sent was " + serverMessage); System.out.println("The message the server sent was " + serverMessage);
OutputStream os = socket.getOutputStream();
PrintStream ps = new PrintStream(os);
ps.println("-- Thank you!");
} }
} else { } else {
//--------------------------------------------------------------
Socket socket = new Socket(LOCALHOST, 2317);
OutputStream os = socket.getOutputStream();
PrintStream ps = new PrintStream(os);
ps.println("-- Client Refused Connection");
System.out.println("Client Refused Connection"); System.out.println("Client Refused Connection");
socket.close();
//--------------------------------------------------------------
} }
...@@ -64,8 +78,8 @@ public class SeversonAssignment2_Client { ...@@ -64,8 +78,8 @@ public class SeversonAssignment2_Client {
System.out.println(e); System.out.println(e);
} }
System.out.println("client exit"); System.out.println("Client Exit");
} }
} }
...@@ -38,7 +38,16 @@ public class SeversonAssingment2_Server { ...@@ -38,7 +38,16 @@ public class SeversonAssingment2_Server {
OutputStream os = clientConnection.getOutputStream(); OutputStream os = clientConnection.getOutputStream();
PrintStream ps = new PrintStream(os); PrintStream ps = new PrintStream(os);
ps.println("This was written by the server"); ps.println("-- Welcome to my Server");
//--------------------------------------------------------------
InputStream is = clientConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String serverMessage = br.readLine();
System.out.println("==================================================");
System.out.println("The message the server sent was " + serverMessage);
//--------------------------------------------------------------
InetAddress localAddress = clientConnection.getLocalAddress(); InetAddress localAddress = clientConnection.getLocalAddress();
InetAddress remoteAddress = clientConnection.getInetAddress(); InetAddress remoteAddress = clientConnection.getInetAddress();
......
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