Skip to content
Snippets Groups Projects
Commit af326c9b authored by courtneythomerson's avatar courtneythomerson
Browse files

Thomerson Homework 1

parent 6af26383
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,20 @@ package MV3500Cohort2018JulySeptember.homework1;
import java.io.*;
import java.net.*;
/**
* =======MODIFICATIONS==============
*
* (A) Examples 1 and 2 were combined into this document manually and the comments on
* each line of code were modified so I could understand what each line of code was
* responsible for.
*
* (B) The NetBean outputs were changed to show each step of the process and clearly
* depict exactly what is going on in the code.
*
* (C) The while loop will stop the program after 5 connections.
*/
/**
* The simplest possible TCP network program. It listens for
* a connection, from telnet (telnet localhost 2317) or a program
......@@ -43,21 +57,12 @@ public class ThomersonAssignment1 {
// Create a new ServerSocket with the input 2317 in the constructor.
// SERVER SOCKET is the socket the client will connect to
// ServerSocket needs to be made only once
ServerSocket serverSocket = new ServerSocket(2317);
//**Set a time out to stop the .accept method from blocking indefinitely
//serverSocket.setSoTimeout(10000);
//**Add a second server socket to listen for clients
//ServerSocket secondServerSocket = new ServerSocket(1990);
//secondServerSocket.setSoTimeout(1);
//Count how many connections have been made
int connectionCount = 0;
while(true){
while(connectionCount < 5){
// The Socket object represents the connection between
// the server and client, including a full duplex
// connection (.accept() is a blocking method)
......@@ -101,7 +106,10 @@ public class ThomersonAssignment1 {
ps.flush();
clientConnection.close();
System.out.println("The last connection has been closed.");
}
System.out.println("\nFive connections have been made - End of program.");
}
catch(Exception e)
{
......
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