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
927f3684
Commit
927f3684
authored
10 months ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
comments
parent
6eb529a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/src/TcpExamples/TcpExample4DispatchServer.java
+11
-6
11 additions, 6 deletions
examples/src/TcpExamples/TcpExample4DispatchServer.java
with
11 additions
and
6 deletions
examples/src/TcpExamples/TcpExample4DispatchServer.java
+
11
−
6
View file @
927f3684
...
@@ -42,16 +42,21 @@ public class TcpExample4DispatchServer
...
@@ -42,16 +42,21 @@ public class TcpExample4DispatchServer
System
.
out
.
println
(
TcpExample4DispatchServer
.
class
.
getName
()
+
" ready to accept socket connections..."
);
System
.
out
.
println
(
TcpExample4DispatchServer
.
class
.
getName
()
+
" ready to accept socket connections..."
);
while
(
true
)
// infinite loop
while
(
true
)
// infinite loop
{
{
clientConnection
=
serverSocket
.
accept
();
// block until connected
clientConnection
=
serverSocket
.
accept
();
// block
!
until connected
connectionCount
++;
// unblocked, got another connection
connectionCount
++;
// unblocked, got another connection
// TODO provide initial message *to the client* that we are handing off to a dispatch thread... because that is polite behavior.
// plenty of code in Example3, we will let TcpExample4HandlerThread introduce itself
System
.
out
.
println
(
"============================================================="
);
System
.
out
.
println
(
"============================================================="
);
System
.
out
.
println
(
TcpExample4DispatchServer
.
class
.
getName
()
+
".handlerThread
invocation
for connection #"
+
connectionCount
+
"..."
);
System
.
out
.
println
(
TcpExample4DispatchServer
.
class
.
getName
()
+
".handlerThread
created
for connection #"
+
connectionCount
+
"..."
);
handlerThread
=
new
TcpExample4HandlerThread
(
clientConnection
);
handlerThread
=
new
TcpExample4HandlerThread
(
clientConnection
);
// hand off the aready-created, connected socket to constructor
handlerThread
.
start
();
// invokes the run() method in that object
handlerThread
.
start
();
// invokes the run() method in that object
System
.
out
.
println
(
TcpExample4DispatchServer
.
class
.
getName
()
+
".handlerThread is
laun
ched
,
a
waiting another
connection..."
);
System
.
out
.
println
(
TcpExample4DispatchServer
.
class
.
getName
()
+
".handlerThread is
now dispat
ched a
nd running, using most recent
connection..."
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Problem with "
+
TcpExample4DispatchServer
.
class
.
getName
()
+
" networking:"
);
// describe what is happening
System
.
out
.
println
(
"Problem with "
+
TcpExample4DispatchServer
.
class
.
getName
()
+
" networking:"
);
// describe what is happening
System
.
out
.
println
(
"Error: "
+
e
);
System
.
out
.
println
(
"Error: "
+
e
);
// Provide more helpful information to user if exception occurs due to running twice at one time
// Provide more helpful information to user if exception occurs due to running twice at one time
...
...
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