diff --git a/assignments/ReportingForDuty.md b/assignments/ReportingForDuty.md index 9dce2a4490181e610de469490c6affdbad0b8f97..b9511a38f34445e00beeb1779fb1d05be59d54ab 100644 --- a/assignments/ReportingForDuty.md +++ b/assignments/ReportingForDuty.md @@ -7,15 +7,21 @@ Be sure to *git update* before, and be sure to *git commit* and *git push* after More information on your use of Git is in the parent directory [README.md](../../README.md) - Don Brutzman + --- + ### 2021 - Terry is here! +- Brian Pugh + - Kurt Reynolds - Rick Lentz +- Max Schlessel + - Nick Hittner - Matt Robinson @@ -28,6 +34,10 @@ More information on your use of Git is in the parent directory [README.md](../.. - Justin McNeely +- John Allen + +--- + ### 2020 - Bernd Weissenberger diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework1/AllenTcpExample1Telnet1.java b/assignments/src/MV3500Cohort2021JulySeptember/homework1/AllenTcpExample1Telnet1.java new file mode 100644 index 0000000000000000000000000000000000000000..2f3717e501458917d7676ac19ac8cbe4ae380e8a --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework1/AllenTcpExample1Telnet1.java @@ -0,0 +1,92 @@ +package MV3500Cohort2021JulySeptember.homework1;; + +import java.io.*; +import java.net.*; +import java.io.*; +import java.net.*; +import java.io.*; +import java.net.*; +import java.io.*; +import java.net.*; + +/** + * The simplest possible TCP network program. It listens for + * a connection, from telnet (telnet localhost 2317) or a program + * you write, which we will do later. Right now the TcpExample simply + * writes a string in response to a connection. + * + * Modifying his program is the basis for Assignment 1. + * + * Testing the running server program from telnet looks like this: + * + * it154916:projects mcgredo$ telnet localhost 2317 + * Trying ::1... + * Connected to localhost. + * Escape character is '^]'. + * This was written by the server + * Connection closed by foreign host. + * + * Notice that "This was written by the server" matches + * what is written by the code below, over the output stream. + * + * After this first connection the program below drops out + * the bottom of the program, and does not repeat itself. + * The program exits. + * + * @author mcgredo + * @author brutzman + */ +public class AllenTcpExample1Telnet1 +{ + /** + * Program invocation, execution starts here + * @param args command-line arguments + */ + public static void main(String[] args) + { + try + { + System.out.println("TcpExample1Telnet has started and is waiting for a connection."); + System.out.println(" help: https://savage.nps.edu/Savage/developers.html#telnet"); + System.out.println(" enter (telnet localhost 2317) or (nc localhost 2317)..." ); + + // The ServerSocket waits for a connection from a client. + // It returns a Socket object when the connection occurs. + ServerSocket serverSocket = new ServerSocket(2317); + + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + + // The Socket object represents the connection between + // the server and client, including a full duplex connection + try (Socket clientConnection = serverSocket.accept()) // wait here for a client to connect + { + // OK we got something, time to respond! + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + ps.println("This client response was written by John Allen "); // to remote client + ps.println("MOVES 2021 Cohort is well described by Johnny Smiles."); + System.out.println("This server response was written by John Allen " ); // to server console + + // "flush()" in important in that it forces a write + // across what is in fact a slow connection + ps.flush(); + } + System.out.println(" completed successfully."); + } + catch(IOException e) + { + System.err.println(" Pardon the interruption, networking issue"); // describe what is happening + System.err.println(e); + // Provide more helpful information to user if exception occurs due to running twice at one time + + // brute force exception checking, can be brittle if exception message changes + // if (e.getMessage().equals("Address already in use: NET_Bind")) + if (e instanceof java.net.BindException) + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework1/HittnerDomTcpExample1Telnet.java b/assignments/src/MV3500Cohort2021JulySeptember/homework1/HittnerDomTcpExample1Telnet.java new file mode 100644 index 0000000000000000000000000000000000000000..3ba4381f1ad60668101abdd5a16b4a0283e5f2cd --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework1/HittnerDomTcpExample1Telnet.java @@ -0,0 +1,63 @@ +package MV3500Cohort2021JulySeptember.homework1; + + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.ServerSocket; +import java.net.Socket; + +/** + * + * @author adfis + */ + + +public class HittnerDomTcpExample1Telnet { + public static void main(String[] args) + { + try + { + System.out.println("TcpExample1Telnet has started and is waiting for a connection."); + System.out.println(" help: https://savage.nps.edu/Savage/developers.html#telnet"); + System.out.println(" enter (telnet localhost 2317) or (nc localhost 2317)..." ); + + // The ServerSocket waits for a connection from a client. + // It returns a Socket object when the connection occurs. + ServerSocket serverSocket = new ServerSocket(2317); + + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + + // The Socket object represents the connection between + // the server and client, including a full duplex connection + try (Socket clientConnection = serverSocket.accept()) { + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + ps.println("Client response was brought to you by the Domo"); // to remote clientnc + ps.println("DomsaMom"); + System.out.println("Client response was brought to you by the Domo"); // to server console + System.out.println("DomsaMom"); + + // "flush()" in important in that it forces a write + // across what is in fact a slow connection + ps.flush(); + } + System.out.println("TcpExample1 completed successfully."); + } + catch(IOException e) + { + System.err.println("Problem with TcpExample1Telnet networking:"); // describe what is happening + System.err.println("Error: " + e); + // Provide more helpful information to user if exception occurs due to running twice at one time + + // brute force exception checking, can be brittle if exception message changes + // if (e.getMessage().equals("Address already in use: NET_Bind")) + if (e instanceof java.net.BindException) + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework1/ReynoldsTcpExample1Telnet1.java b/assignments/src/MV3500Cohort2021JulySeptember/homework1/ReynoldsTcpExample1Telnet1.java new file mode 100644 index 0000000000000000000000000000000000000000..2758b2dcafecba78d0f32534a03d3aaa2f1934ba --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework1/ReynoldsTcpExample1Telnet1.java @@ -0,0 +1,63 @@ +package MV3500Cohort2021JulySeptember.homework1; + + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.ServerSocket; +import java.net.Socket; + +/** + * + * @author kReynolds + */ + + +public class ReynoldsTcpExample1Telnet1 { + public static void main(String[] args) + { + try + { + System.out.println("TcpExample1Telnet has started and is waiting for a connection."); + System.out.println(" help: https://savage.nps.edu/Savage/developers.html#telnet"); + System.out.println(" enter (telnet localhost 2317) or (nc localhost 2317)..." ); + + // The ServerSocket waits for a connection from a client. + // It returns a Socket object when the connection occurs. + ServerSocket serverSocket = new ServerSocket(2317); + + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + + // The Socket object represents the connection between + // the server and client, including a full duplex connection + try (Socket clientConnection = serverSocket.accept()) { + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + ps.println("Client response was brought to you by the Domo"); // to remote clientnc + ps.println("DomsaMom"); + System.out.println("Client response was brought to you by the Domo"); // to server console + System.out.println("DomsaMom"); + + // "flush()" in important in that it forces a write + // across what is in fact a slow connection + ps.flush(); + } + System.out.println("TcpExample1 completed successfully."); + } + catch(IOException e) + { + System.err.println("Problem with TcpExample1Telnet networking:"); // describe what is happening + System.err.println("Error: " + e); + // Provide more helpful information to user if exception occurs due to running twice at one time + + // brute force exception checking, can be brittle if exception message changes + // if (e.getMessage().equals("Address already in use: NET_Bind")) + if (e instanceof java.net.BindException) + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework1/RobinsonTcpExample1Telnet.java b/assignments/src/MV3500Cohort2021JulySeptember/homework1/RobinsonTcpExample1Telnet.java new file mode 100644 index 0000000000000000000000000000000000000000..608af41e7dee3bfa8a370716eb6e513b28aba79f --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework1/RobinsonTcpExample1Telnet.java @@ -0,0 +1,60 @@ +package MV3500Cohort2021JulySeptember.homework1; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.ServerSocket; +import java.net.Socket; + +/** + * + * @author mrobi + */ +public class RobinsonTcpExample1Telnet { + public static void main(String[] args) + { + try + { + System.out.println("TcpExample1Telnet has started and is waiting for a connection."); + System.out.println(" help: https://savage.nps.edu/Savage/developers.html#telnet"); + System.out.println(" enter (telnet localhost 2317) or (nc localhost 2317)..." ); + + // The ServerSocket waits for a connection from a client. + // It returns a Socket object when the connection occurs. + ServerSocket serverSocket = new ServerSocket(2317); + + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + + // The Socket object represents the connection between + // the server and client, including a full duplex connection + try (Socket clientConnection = serverSocket.accept()) { + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + ps.println("Client response was written by Matt's server TcpExample1."); // to remote clientnc + ps.println("Can you hear me?"); + System.out.println("Client response was written by Matt's server TcpExample1."); // to server console + System.out.println("Yes"); + + // "flush()" in important in that it forces a write + // across what is in fact a slow connection + ps.flush(); + } + System.out.println("TcpExample1 completed successfully."); + } + catch(IOException e) + { + System.err.println("Problem with FisherTCPExample1Telnet networking:"); // describe what is happening + System.err.println("Error: " + e); + // Provide more helpful information to user if exception occurs due to running twice at one time + + // brute force exception checking, can be brittle if exception message changes + // if (e.getMessage().equals("Address already in use: NET_Bind")) + if (e instanceof java.net.BindException) + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } +} diff --git a/assignments/src/MV3500Cohort2021JulySeptember/homework1/SchlesselTcpExample1Telnet.java b/assignments/src/MV3500Cohort2021JulySeptember/homework1/SchlesselTcpExample1Telnet.java new file mode 100644 index 0000000000000000000000000000000000000000..fa2565785de76a5753d4368ab87c75adce506373 --- /dev/null +++ b/assignments/src/MV3500Cohort2021JulySeptember/homework1/SchlesselTcpExample1Telnet.java @@ -0,0 +1,65 @@ +package TcpExamples; + +import java.io.*; +import java.net.*; + +/** + * Homework 1 + * + * @author max schlessel + */ +public class SchlesselTcpExample1Telnet +{ + /** + * Program invocation, execution starts here + * @param args command-line arguments + */ + public static void main(String[] args) + { + try + { + System.out.println(SchlesselTcpExample1Telnet.class.getName() + " has started and is waiting for a connection."); + System.out.println(" help: https://savage.nps.edu/Savage/developers.html#telnet"); + System.out.println(" enter (telnet localhost 2317) or (nc localhost 2317)..." ); + + // The ServerSocket waits for a connection from a client. + // It returns a Socket object when the connection occurs. + ServerSocket serverSocket = new ServerSocket(2317); + + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + + // The Socket object represents the connection between + // the server and client, including a full duplex connection + try (Socket clientConnection = serverSocket.accept()) // wait here for a client to connect + { + // OK we got something, time to respond! + // Use Java io classes to write text (as opposed to + // unknown bytes of some sort) to the client + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + ps.println("This client response was written by Max's client " + SchlesselTcpExample1Telnet.class.getName()); // to remote client + ps.println("aka the shot heard round the world"); + System.out.println("This server response was written by Max's server " + SchlesselTcpExample1Telnet.class.getName()); // to server console + System.out.println("boom"); + + // "flush()" in important in that it forces a write + // across what is in fact a slow connection + ps.flush(); + } + System.out.println(SchlesselTcpExample1Telnet.class.getName() + " completed successfully."); + } + catch(IOException e) + { + System.err.println("Exception with " + SchlesselTcpExample1Telnet.class.getName() + " networking:"); // describe what is happening + System.err.println(e); + // Provide more helpful information to user if exception occurs due to running twice at one time + + // brute force exception checking, can be brittle if exception message changes + // if (e.getMessage().equals("Address already in use: NET_Bind")) + if (e instanceof java.net.BindException) + System.err.println("*** Be sure to stop any other running instances of programs using this port!"); + } + } +} diff --git a/presentations/00_ConfiguringJavaNetbeansGit.pdf b/presentations/00_ConfiguringJavaNetbeansGit.pdf index 04646de71d84674ffcb950b43388915ea0e94d44..f8a54eadac67d32b24bd4def771bb596df5dfc47 100644 Binary files a/presentations/00_ConfiguringJavaNetbeansGit.pdf and b/presentations/00_ConfiguringJavaNetbeansGit.pdf differ diff --git a/presentations/00_ConfiguringJavaNetbeansGit.pptx b/presentations/00_ConfiguringJavaNetbeansGit.pptx index 465c37a8abb188328af3e03100d5dc6dd430fcb9..a71e57da845af97ae6c69ba9d8333996ff883db2 100644 Binary files a/presentations/00_ConfiguringJavaNetbeansGit.pptx and b/presentations/00_ConfiguringJavaNetbeansGit.pptx differ