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

Merge origin/master

parents 8007f9a7 49a01267
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,14 @@ Deliverables:
0. Think of a simple challenge/response protocol that you wish to portray.
1. Apply your own customized version of Assignment 3 showing both Server and Client programs.
2. Include comments describing your modifications.
1. Challenge/response scenarios
2. IPv4 versus IPv6
3. Joke telling and riddles?
4. [Message of the Day (MOTD)](https://en.wikipedia.org/wiki/Motd_(Unix))
5. Variations on a theme, protocol handshaking
6. Connecting two different hosts - chat
7. Something for your thesis!
2. Include comments describing your modifications (aka Documentation).
3. Include documentation of one or more sessions, including operation.
4. Create a simple illustration of the communications exchange in a UML Sequence Diagram.
......
......@@ -20,7 +20,7 @@ public class TcpClient {
public static void main(String[] args) {
try {
while (true) {
System.out.println("creating socket");
System.out.println("TcpClient creating socket...");
// We request an IP to connect to ("localhost") and
// port number at that IP (2317). This establishes
......@@ -29,13 +29,14 @@ public class TcpClient {
// connections.
Socket socket = new Socket(LOCALHOST, 2317); // locohost?
// Now hook everything up (i.e. set up the streams), Java style:
InputStream is = socket.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
// 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!");
......
......@@ -31,17 +31,21 @@ public class TcpServer {
// Notice that it is outside the loop; ServerSocket
// needs to be made only once.
System.out.println("TcpServer has started..."); // it helps debugging to put this on console first
ServerSocket serverSocket = new ServerSocket(2317);
// Server is up and waiting (i.e. "blocked" or paused)
// Loop, infinitely, waiting for client connections.
// Stop the program somewhere else.
while (true)
{
Socket clientConnection = serverSocket.accept(); // block until connected
Socket clientConnection = serverSocket.accept(); // block until connected to a client
// Now hook everything up (i.e. set up the streams), Java style:
OutputStream os = clientConnection.getOutputStream();
PrintStream ps = new PrintStream(os);
PrintStream ps = new PrintStream(os);
ps.println("This was written by the server");
ps.println("This was written by the server"); // this goes back to client!
// Print some information locally about the Socket
// connection. This includes the port and IP numbers
......
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