diff --git a/.gitignore b/.gitignore index 21c04d06199b31e4608335eba3608bd9d63a71ba..810b6192fe9d1119740f0766031a5383bdda6548 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,4 @@ /projects/Assignments/dist/ /deliverables/build/ /projects/TcpExample3/Server/TcpServer/build/ -/projects/TcpExample3/Client/TcpClient/build/ \ No newline at end of file +/projects/TcpExample3/Client/TcpClient/build/ diff --git a/deliverables/nbproject/project.properties b/deliverables/nbproject/project.properties index 749fb22f3de7a1f6fb70257e0554b050cf760256..d108cb02148d80536d45166cff48f0f9d0fc25e5 100644 --- a/deliverables/nbproject/project.properties +++ b/deliverables/nbproject/project.properties @@ -1,9 +1,10 @@ annotation.processing.enabled=true annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=MV3500 Deliverables +application.vendor=don build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: @@ -26,10 +27,15 @@ dist.archive.excludes= dist.dir=dist dist.jar=${dist.dir}/MV3500_Deliverables.jar dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= excludes= +file.reference.dis-enums-1.3.jar=../lib/dis-enums-1.3.jar +file.reference.open-dis_4.16.jar=../lib/open-dis_4.16.jar includes=** jar.compress=false -javac.classpath= +javac.classpath=\ + ${file.reference.open-dis_4.16.jar}:\ + ${file.reference.dis-enums-1.3.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false @@ -54,6 +60,7 @@ javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= +main.class=MV3500Cohort2018JulySeptember.homework1.CainAssignment1 meta.inf.dir=${src.dir}/META-INF mkdist.disabled=true platform.active=default_platform diff --git a/deliverables/nbproject/project.xml b/deliverables/nbproject/project.xml index 1d2ea4beb4f7f8320e545e1a40ae4d3b59682874..8915a334fa6bcf8ad15f1b733e419a24ee328d12 100644 --- a/deliverables/nbproject/project.xml +++ b/deliverables/nbproject/project.xml @@ -11,5 +11,9 @@ <root id="test.src.dir"/> </test-roots> </data> + <spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1"> + <word>localhost</word> + <word>multicast</word> + </spellchecker-wordlist> </configuration> </project> diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainAssignment2.4Client.png b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainAssignment2.4Client.png new file mode 100644 index 0000000000000000000000000000000000000000..21b35c4325a18d21365b41b6e8c07167f7ebeeca Binary files /dev/null and b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainAssignment2.4Client.png differ diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainAssignment2.4Server.png b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainAssignment2.4Server.png new file mode 100644 index 0000000000000000000000000000000000000000..f772c6bb643ea1cc545302d036d3d5be868a6c94 Binary files /dev/null and b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainAssignment2.4Server.png differ diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainTcpClient.java b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainTcpClient.java new file mode 100644 index 0000000000000000000000000000000000000000..84fa0846ce1713ae38b9c94e28fad3ea09438a96 --- /dev/null +++ b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainTcpClient.java @@ -0,0 +1,55 @@ +package MV3500Cohort2018JulySeptember.homework2; + +import java.net.Socket; +import java.io.*; +import java.net.*; + +/** + * credit to author mcgredo + */ +public class CainTcpClient { + + public final static String LOCALHOST = "0:0:0:0:0:0:0:1"; // String constant, i.e. 127.0.0.1 + + public static void main(String[] args) { + try { + while (true) { + System.out.println("creating socket"); + + // * Changed IP from 2317 to 2468. + Socket socket = new Socket(LOCALHOST, 2468); // locohost? + + OutputStream os = socket.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os); + BufferedWriter bw = new BufferedWriter(osw); + + InputStream is = socket.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + + String inputMessage = "Client: We are under attack! What do we do? "; + System.out.println("Client: we told the server: We are under attack! What do we do? "); + String sendMessage = inputMessage + "\n"; + bw.write(sendMessage); + bw.flush(); + + String input = br.readLine(); + System.out.println("Client: copy, server: " + input); + +// String serverMessage = br.readLine(); + System.out.println("Client: We are on our way!\n" ); // + serverMessage + + String update = br.readLine(); +// String sendUpdate = update + "\n"; +// System.out.println("Answer:" + sendUpdate); + + } // end while(true) + } catch (IOException e) { + System.out.println("Problem with client: "); // describe what is happening + System.out.println(e); + } + // program exit: tell somebody about that + System.out.println("client exit"); + } + +} diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainTcpServer.java b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainTcpServer.java new file mode 100644 index 0000000000000000000000000000000000000000..4ef063425e64d28f99acf21a00be85ad0aec1d92 --- /dev/null +++ b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/CainTcpServer.java @@ -0,0 +1,73 @@ +package MV3500Cohort2018JulySeptember.homework2; + +import java.io.*; +import java.net.*; + +/** + * + * telnet localhost 2468 + * telnet <ipOfServersLaptop> 2468 + * credit to author mcgredo + */ +public class CainTcpServer +{ + + public static void main(String[] args) + { + try + { + // * Changed IP from 2317 to 2468. + ServerSocket serverSocket = new ServerSocket(2468); + + int x = 1; + while(x<=10) + { + System.out.println("server here, starting loop #: " + x); + Socket clientConnection = serverSocket.accept(); // block until connected + InputStream is = clientConnection.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String receivedInput = br.readLine(); + System.out.println("Server: the client said: \n" + receivedInput); + + String returnInput; + returnInput = "Get to the choppa!"; // shows up + System.out.println("Server: told the client to Get to the choppa!\n"); + OutputStream os = clientConnection.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os); + BufferedWriter bw = new BufferedWriter(osw); + +// bw.write(returnInput); +// System.out.println("Message volley"); + + PrintStream ps = new PrintStream(os); + ps.println("Get to the choppa!"); + ps.println(returnInput); + + InetAddress localAddress = clientConnection.getLocalAddress(); + InetAddress remoteAddress = clientConnection.getInetAddress(); + + int localPort = clientConnection.getLocalPort(); + int remotePort = clientConnection.getPort(); + + System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " + + remoteAddress.toString() + ", " + remotePort + " ))"); + + // Notice the use of flush() and close(). Without + // the close() to Socket object may stay open for + // a while after the client has stopped needing this + // connection. Close() explicitly ends the connection. + ps.flush(); + clientConnection.close(); + x++; + } + } + catch(Exception e) + { + // cosmetic change to print line + System.out.println("You got problems! Deal with it"); + } + + } + +} \ No newline at end of file diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/FurrTcpClient.java b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/FurrTcpClient.java new file mode 100644 index 0000000000000000000000000000000000000000..9655970545861c38ae1a9df226e859f5cf261f43 --- /dev/null +++ b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/FurrTcpClient.java @@ -0,0 +1,60 @@ + +package MV3500Cohort2018JulySeptember.homework2.Furr; + +import java.io.*; +import java.net.*; + +/** + * Before, we always used telnet to connect to the server. + * Here we are now writing our own program to do the connection. + * + * As you will see, when we run this after we start the server + * we will see the same string telnet printed, sent by the server. + * The output at the server will show different socket pairs for + * each time we ran it. + * + * @author mcgredo + */ +public class FurrTcpClient { + + public final static String LOCALHOST = "0:0:0:0:0:0:0:1"; // String constant, i.e. 127.0.0.1 + + public static void main(String[] args) + { + try + { + while(true) + { + System.out.println("creating socket"); + + // We request an IP to connect to ("localhost") and + // port number at that IP (2317). This establishes + // a connection to that IP in the form of the Socket + // object; the server uses a ServerSocket to wait for + // connections. + Socket socket = new Socket(LOCALHOST, 2317); // locohost? + + // Read the single line written by the server. We'd + // do things a bit differently if many lines to be read + // from the server, instead of one only. + InputStream is = socket.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + + String serverMessage = br.readLine(); + System.out.println("=================================================="); + System.out.println("Now we're talking!"); + System.out.println("The message the server sent was " + serverMessage); + // socket gets closed, either automatically/silently this code (or possibly by server) + } // end while(true) + } + catch(IOException e) + { + System.out.println("Problem with client: "); // describe what is happening + System.out.println(e); + } + // program exit: tell somebody about that + System.out.println("client exit"); + } + +} diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/FurrTcpServer.java b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/FurrTcpServer.java new file mode 100644 index 0000000000000000000000000000000000000000..d501f3c3e2f759f9808a471d60c4c6d9980cb01b --- /dev/null +++ b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/FurrTcpServer.java @@ -0,0 +1,83 @@ +package MV3500Cohort2018JulySeptember.homework2.Furr; + +import java.io.*; +import java.net.*; + +/** + * Very slightly more complex than example1. A complete copy of + * example 2. The only thing this does + * differently is introduce a loop into the response, so you don't + * have to restart the program after one response. Also, it prints + * out the socket pair the server sees. Run the program via telnet + * several times and compare the socket pairs. + * + * telnet localhost 2317 + * + * If you're sophisticated you can contact the instructor's computer + * while running this program. + * + * telnet <ipOfServersLaptop> 2317 + * + * And have him display the socket pairs he got. + * @author mcgredo + */ +public class FurrTcpServer +{ + + public static void main(String[] args) + { + try + { + // ServerSocket waits for a connection from a client. + // Notice that it is outside the loop; ServerSocket + // needs to be made only once. + + ServerSocket serverSocket = new ServerSocket(2317); + + // Loop, infinitely, waiting for client connections. + // Stop the program somewhere else. + while(true) + { + Socket clientConnection = serverSocket.accept(); // block until connected + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + ps.println("This was written by the server"); + + // Print some information locally about the Socket + // connection. This includes the port and IP numbers + // on both sides (the socket pair.) + + InetAddress localAddress = clientConnection.getLocalAddress(); + InetAddress remoteAddress = clientConnection.getInetAddress(); + + int localPort = clientConnection.getLocalPort(); + int remotePort = clientConnection.getPort(); + + // My socket pair connection looks like this, to localhost: + // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 )) + // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54881 )) + // + // Why is the first IP/port the same, while the second set has + // different ports? + + + System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " + + remoteAddress.toString() + ", " + remotePort + " ))"); + + // Notice the use of flush() and close(). Without + // the close() to Socket object may stay open for + // a while after the client has stopped needing this + // connection. Close() explicitly ends the connection. + ps.flush(); + clientConnection.close(); // like it or not, you're outta here! + } + } + catch(IOException e) + { + System.out.println("problem with networking"); + } + + } + +} \ No newline at end of file diff --git a/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr_Made_Up_UML_Diagram.jpg b/deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/Furr_Made_Up_UML_Diagram.jpg similarity index 100% rename from deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr_Made_Up_UML_Diagram.jpg rename to deliverables/src/MV3500Cohort2018JulySeptember/homework2/Furr/Furr_Made_Up_UML_Diagram.jpg diff --git a/presentations/03_TCPIP.pptx b/presentations/03_TCPIP.pptx index 6a7ac11770342204cdc0482c1f3315dbbcdd8051..0e84e3f0217145350c02739d9728590feb3e94d2 100644 Binary files a/presentations/03_TCPIP.pptx and b/presentations/03_TCPIP.pptx differ diff --git a/projects/TcpExample3/Server/TcpServer/nbproject/genfiles.properties b/projects/TcpExample3/Server/TcpServer/nbproject/genfiles.properties index 021c054154a33e9c1ce32fedcc20420946bccc15..75abc2d2c870d4c670954f9ad4a62fbaea4a955b 100644 --- a/projects/TcpExample3/Server/TcpServer/nbproject/genfiles.properties +++ b/projects/TcpExample3/Server/TcpServer/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=c6e94055 +build.xml.data.CRC32=db5607e2 build.xml.script.CRC32=14215a97 build.xml.stylesheet.CRC32=8064a381@1.80.1.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=c6e94055 +nbproject/build-impl.xml.data.CRC32=db5607e2 nbproject/build-impl.xml.script.CRC32=c8e98896 nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48