Skip to content
Snippets Groups Projects
Commit 67ceeca8 authored by John Furr's avatar John Furr
Browse files

New git folder

parent 5ed66a0a
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ package MV3500Cohort2018JulySeptember.homework2.Furr; ...@@ -3,6 +3,7 @@ package MV3500Cohort2018JulySeptember.homework2.Furr;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.Scanner;
/** /**
* Before, we always used telnet to connect to the server. * Before, we always used telnet to connect to the server.
...@@ -14,6 +15,7 @@ import java.net.*; ...@@ -14,6 +15,7 @@ import java.net.*;
* each time we ran it. * each time we ran it.
* *
* @author mcgredo * @author mcgredo
* cd /cygdrive/e/Documents/NPS/MV3500_Internetwork_Communications/NetworkedGraphicsMV3500/deliverables/build/classes/MV3500Cohort2018JulySeptember/homework2/Furr
*/ */
public class FurrTcpClient { public class FurrTcpClient {
...@@ -21,6 +23,7 @@ public class FurrTcpClient { ...@@ -21,6 +23,7 @@ public class FurrTcpClient {
public static void main(String[] args) public static void main(String[] args)
{ {
boolean openConnection = true;
try try
{ {
while(true) while(true)
...@@ -44,7 +47,24 @@ public class FurrTcpClient { ...@@ -44,7 +47,24 @@ public class FurrTcpClient {
String serverMessage = br.readLine(); String serverMessage = br.readLine();
System.out.println("=================================================="); System.out.println("==================================================");
System.out.println("Now we're talking!"); System.out.println("Now we're talking!");
System.out.println("The message the server sent was " + serverMessage); System.out.println("The message the server sent was " + serverMessage+"\n");
serverMessage = br.readLine();
while(serverMessage != null)
{
serverMessage = br.readLine();
System.out.println(serverMessage);
}
int x=0;
while(x<5)//openConnection)
{
Scanner in = new Scanner(System.in);
String s = in.nextLine();
OutputStream os = socket.getOutputStream();
PrintStream ps = new PrintStream(os);
ps.println(s);
x++;
}
// socket gets closed, either automatically/silently this code (or possibly by server) // socket gets closed, either automatically/silently this code (or possibly by server)
} // end while(true) } // end while(true)
} }
......
...@@ -20,12 +20,27 @@ import java.net.*; ...@@ -20,12 +20,27 @@ import java.net.*;
* *
* And have him display the socket pairs he got. * And have him display the socket pairs he got.
* @author mcgredo * @author mcgredo
*
* to change to build file:
* cd /cygdrive/e/Documents/NPS/MV3500_Internetwork_Communications/NetworkedGraphicsMV3500/deliverables/build/classes/MV3500Cohort2018JulySeptember/homework2/Furr
*/ */
public class FurrTcpServer public class FurrTcpServer
{ {
public static void main(String[] args) public static void main(String[] args)
{ {
String[] responses = new String[10];
responses[0] = "Hello";
responses[1] = "Are you there?";
responses[2] = "Glad you stopped by to say hi";
responses[3] = "What are you planning on doing today?";
responses[4] = "Not that this program cares, these are pre-recored";
responses[5] = "That's right, you can say whatever you want I'll say the samething";
responses[6] = "Makes this chat less exciting doesn't it.";
responses[7] = "Your hair looks nice today";
responses[8] = "The FBI said so.";
responses[9] = "This is really teadious, I'm done talking. Good bye!";
int index =0;
try try
{ {
// ServerSocket waits for a connection from a client. // ServerSocket waits for a connection from a client.
...@@ -41,9 +56,16 @@ public class FurrTcpServer ...@@ -41,9 +56,16 @@ public class FurrTcpServer
Socket clientConnection = serverSocket.accept(); // block until connected Socket clientConnection = serverSocket.accept(); // block until connected
OutputStream os = clientConnection.getOutputStream(); OutputStream os = clientConnection.getOutputStream();
PrintStream ps = new PrintStream(os); PrintStream ps = new PrintStream(os);
InputStream serverIS = clientConnection.getInputStream();
InputStreamReader serverISR = new InputStreamReader(serverIS);
BufferedReader br = new BufferedReader(serverISR);
ps.println("This was written by the server"); ps.println("This was written by the server");
System.out.println(br+"\n");
ps.println(responses[index]);
index ++;
// Print some information locally about the Socket // Print some information locally about the Socket
// connection. This includes the port and IP numbers // connection. This includes the port and IP numbers
// on both sides (the socket pair.) // on both sides (the socket pair.)
......
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