Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
af326c9b
Commit
af326c9b
authored
7 years ago
by
courtneythomerson
Browse files
Options
Downloads
Patches
Plain Diff
Thomerson Homework 1
parent
6af26383
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deliverables/src/MV3500Cohort2018JulySeptember/homework1/ThomersonAssignment1.java
+18
-10
18 additions, 10 deletions
...hort2018JulySeptember/homework1/ThomersonAssignment1.java
with
18 additions
and
10 deletions
deliverables/src/MV3500Cohort2018JulySeptember/homework1/ThomersonAssignment1.java
+
18
−
10
View file @
af326c9b
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment