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
a86d218f
Commit
a86d218f
authored
6 years ago
by
Peter
Browse files
Options
Downloads
Patches
Plain Diff
Pending documentation
parent
8a40c326
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/SeversonAssignment1.java
+9
-0
9 additions, 0 deletions
...ohort2018JulySeptember/homework1/SeversonAssignment1.java
with
9 additions
and
0 deletions
deliverables/src/MV3500Cohort2018JulySeptember/homework1/SeversonAssignment1.java
+
9
−
0
View file @
a86d218f
...
...
@@ -25,22 +25,30 @@ public class SeversonAssignment1 {
try
{
//Instantiate socket and wait for connection
ServerSocket
serverSocket
=
new
ServerSocket
(
2317
);
//Count the number of connections
int
connection
=
0
;
//Loop until client connection is made
while
(
true
)
{
//Socket making connection with the client
Socket
clientConnection
=
serverSocket
.
accept
();
//number of connections is incremented by one when the connection occurs
connection
++;
//write output text to the client and server
OutputStream
os
=
clientConnection
.
getOutputStream
();
PrintStream
ps
=
new
PrintStream
(
os
);
//connection responses to the server and client
ps
.
println
(
"This client response was written by server"
);
// to remote client
System
.
out
.
println
(
"This server response was written by server"
);
// to server console
ps
.
println
(
"Got another connection! "
+
"--Number "
+
connection
);
//Print port and IP addresses of the server connection
InetAddress
localAddress
=
clientConnection
.
getLocalAddress
();
InetAddress
remoteAddress
=
clientConnection
.
getInetAddress
();
...
...
@@ -49,6 +57,7 @@ public class SeversonAssignment1 {
System
.
out
.
println
(
"Socket pair: (( "
+
localAddress
.
toString
()
+
", "
+
localPort
+
" ), ( "
+
remoteAddress
.
toString
()
+
", "
+
remotePort
+
" ))"
);
//close the connection and inform the client of the close
ps
.
println
(
"The client connection is closed ---- BYE!"
);
ps
.
flush
();
clientConnection
.
close
();
...
...
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