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
d6b412f2
Commit
d6b412f2
authored
2 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
explanatory comments
parent
5f82b7f9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/src/TcpExamples/TcpExample1Telnet.java
+1
-1
1 addition, 1 deletion
examples/src/TcpExamples/TcpExample1Telnet.java
examples/src/TcpExamples/TcpExample2ConnectionCounting.java
+4
-3
4 additions, 3 deletions
examples/src/TcpExamples/TcpExample2ConnectionCounting.java
with
5 additions
and
4 deletions
examples/src/TcpExamples/TcpExample1Telnet.java
+
1
−
1
View file @
d6b412f2
...
@@ -58,7 +58,7 @@ public class TcpExample1Telnet
...
@@ -58,7 +58,7 @@ public class TcpExample1Telnet
// The Socket object represents the connection between
// The Socket object represents the connection between
// the server and client, including a full duplex connection
// the server and client, including a full duplex connection
try
(
Socket
clientConnection
=
serverSocket
.
accept
())
// wait here for a client to connect
try
(
Socket
clientConnection
=
serverSocket
.
accept
())
//
listen,
wait here for a client to connect
{
{
// OK we got something, time to respond!
// OK we got something, time to respond!
// Use Java io classes to write text (as opposed to
// Use Java io classes to write text (as opposed to
...
...
This diff is collapsed.
Click to expand it.
examples/src/TcpExamples/TcpExample2ConnectionCounting.java
+
4
−
3
View file @
d6b412f2
...
@@ -36,6 +36,7 @@ public class TcpExample2ConnectionCounting
...
@@ -36,6 +36,7 @@ public class TcpExample2ConnectionCounting
{
{
try
try
{
{
// welcome aboard messages
System
.
out
.
println
(
"TcpExample2ConnectionCounting has started and is waiting for a connection."
);
System
.
out
.
println
(
"TcpExample2ConnectionCounting has started and is waiting for a connection."
);
System
.
out
.
println
(
" help: https://savage.nps.edu/Savage/developers.html#telnet"
);
System
.
out
.
println
(
" help: https://savage.nps.edu/Savage/developers.html#telnet"
);
System
.
out
.
println
(
" Windows ipconfig (or Mac ifconfig) indicates current IPv4_Address (for example local wireless IP address)"
);
System
.
out
.
println
(
" Windows ipconfig (or Mac ifconfig) indicates current IPv4_Address (for example local wireless IP address)"
);
...
@@ -56,8 +57,8 @@ public class TcpExample2ConnectionCounting
...
@@ -56,8 +57,8 @@ public class TcpExample2ConnectionCounting
while
(
true
)
while
(
true
)
{
{
// serverSocket.accept() blocks! then proceeds once a connection is "accept"ed
// serverSocket.accept() blocks! then proceeds once a connection is "accept"ed
try
(
Socket
clientConnection
=
serverSocket
.
accept
())
{
try
(
Socket
clientConnection
=
serverSocket
.
accept
())
{
// the accept() method blocks here until a client connects
connectionCount
++;
// got another one!
connectionCount
++;
// got another one!
a client has connected
OutputStream
os
=
clientConnection
.
getOutputStream
();
OutputStream
os
=
clientConnection
.
getOutputStream
();
PrintStream
ps
=
new
PrintStream
(
os
);
PrintStream
ps
=
new
PrintStream
(
os
);
...
@@ -109,7 +110,7 @@ public class TcpExample2ConnectionCounting
...
@@ -109,7 +110,7 @@ public class TcpExample2ConnectionCounting
ps
.
flush
();
ps
.
flush
();
}
}
}
}
}
}
catch
(
IOException
e
)
catch
(
IOException
e
)
{
{
System
.
err
.
println
(
"Problem with "
+
TcpExample2ConnectionCounting
.
class
.
getName
()
+
" networking:"
);
// describe what is happening
System
.
err
.
println
(
"Problem with "
+
TcpExample2ConnectionCounting
.
class
.
getName
()
+
" networking:"
);
// describe what is happening
...
...
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