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
594f76bc
Commit
594f76bc
authored
5 years ago
by
brutzman
Browse files
Options
Downloads
Patches
Plain Diff
update example and terminal log
parent
b555debc
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
CourseExamples/src/TcpExamples/TcpExample1Telnet.java
+8
-6
8 additions, 6 deletions
CourseExamples/src/TcpExamples/TcpExample1Telnet.java
CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt
+17
-6
17 additions, 6 deletions
CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt
with
25 additions
and
12 deletions
CourseExamples/src/TcpExamples/TcpExample1Telnet.java
+
8
−
6
View file @
594f76bc
...
...
@@ -30,19 +30,20 @@ import java.net.*;
public
class
TcpExample1Telnet
{
@SuppressWarnings
(
"ConvertToTryWithResources"
)
public
static
void
main
(
String
[]
args
)
{
try
{
System
.
out
.
println
(
"TcpExample1Telnet has started and is waiting for a connection: telnet localhost 2317"
);
System
.
out
.
println
(
"TcpExample1Telnet has started and is waiting for a connection:"
);
System
.
out
.
println
(
"Enter (telnet localhost 2317) or (nc localhost 2317)..."
);
// The ServerSocket waits for a connection from a client.
// It returns a Socket object when the connection occurs.
ServerSocket
serverSocket
=
new
ServerSocket
(
2317
);
// 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
Socket
clientConnection
=
serverSocket
.
accept
();
// Use Java io classes to write text (as opposed to
...
...
@@ -50,16 +51,17 @@ public class TcpExample1Telnet
OutputStream
os
=
clientConnection
.
getOutputStream
();
PrintStream
ps
=
new
PrintStream
(
os
);
ps
.
println
(
"This client response was written by server TcpExample1"
);
// to remote client
System
.
out
.
println
(
"This server response was written by server TcpExample1"
);
// to server console
ps
.
println
(
"This client response was written by server TcpExample1
.
"
);
// to remote client
nc
System
.
out
.
println
(
"This server response was written by server TcpExample1
.
"
);
// to server console
// "flush()" in important in that it forces a write
// across what is in fact a slow connection
ps
.
flush
();
clientConnection
.
close
();
System
.
out
.
println
(
"TcpExample1 completed successfully."
);
}
catch
(
Exception
e
)
catch
(
IO
Exception
e
)
{
System
.
out
.
println
(
"problem with networking: "
+
e
);
}
...
...
This diff is collapsed.
Click to expand it.
CourseExamples/src/TcpExamples/TcpExample1TerminalLog.txt
+
17
−
6
View file @
594f76bc
Invocation instructions:
1. run/debug TcpExample1Telnet.java
2. console: telnet localhost 2317
2. console: nc localhost 2317
alternate: telnet localhost 2217
Program responses:
===================================================
run:
TcpExample1Telnet has started and is waiting for a connection: telnet localhost 2317
This server response was written by server TcpExample1
BUILD SUCCESSFUL (total time: 13 seconds)
TcpExample1Telnet has started and is waiting for a connection:
Enter (telnet localhost 2317) or (nc localhost 2317)...
This server response was written by server TcpExample1.
TcpExample1 completed successfully.
BUILD SUCCESSFUL (total time: 5 seconds)
Telnet window:
===================================================
netcat window:
brutzman@DESKTOP-2S09UKA /cygdrive/c/Program Files/NetBeans_11.0/bin
$ nc localhost 2317
This client response was written by server TcpExample1.
===================================================
Telnet window:
don@it154928 /cygdrive/c/Program Files/NetBeans 8.2
$ telnet localhost 2317
Trying ::1...
Connected to localhost.
Escape character is '^]'.
This client response was written by server TcpExample1
This client response was written by server TcpExample1
.
Connection closed by foreign host.
===================================================
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