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
6fe719b8
Commit
6fe719b8
authored
7 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
improved comments
parent
0283100a
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
projects/TcpExample5/WebExample/src/webexample/WebExample.java
+8
-11
8 additions, 11 deletions
...cts/TcpExample5/WebExample/src/webexample/WebExample.java
with
8 additions
and
11 deletions
projects/TcpExample5/WebExample/src/webexample/WebExample.java
+
8
−
11
View file @
6fe719b8
package
webexample
;
package
webexample
;
import
java.io.*
;
import
java.io.*
;
import
java.net.*
;
import
java.net.*
;
/**
/**
* A very simple
web
reading example that won't work in some circumstances.
* A very simple
http web-page
reading example that won't work in some circumstances.
* But it will in some others.
* But it will in some others.
*
*
* @author mcgredo
* @author mcgredo
...
@@ -40,24 +39,22 @@ public class WebExample {
...
@@ -40,24 +39,22 @@ public class WebExample {
ps
.
print
(
"\r\n\r\n"
);
ps
.
print
(
"\r\n\r\n"
);
ps
.
flush
();
ps
.
flush
();
// Up until now we have been reading one line only.
But
// Up until now we have been reading one line only.
// a web server will write an unknown number of lines.
We
//
But
a web server will write an unknown number of lines.
// read until the transmisson ends.
//
So now we
read until the transmisson ends.
InputStream
is
=
socket
.
getInputStream
();
InputStream
is
=
socket
.
getInputStream
();
InputStreamReader
isr
=
new
InputStreamReader
(
is
);
InputStreamReader
isr
=
new
InputStreamReader
(
is
);
BufferedReader
br
=
new
BufferedReader
(
isr
);
BufferedReader
br
=
new
BufferedReader
(
isr
);
String
line
;
String
line
;
int
count
=
0
;
int
count
=
0
;
while
((
line
=
br
.
readLine
())
!=
null
)
while
((
line
=
br
.
readLine
())
!=
null
)
// read from BufferedReader br one line at a time
{
{
count
++;
count
++;
System
.
out
.
println
(
count
+
": "
+
line
);
System
.
out
.
println
(
count
+
": "
+
line
);
}
}
System
.
out
.
println
(
"web server message finished"
);
System
.
out
.
println
(
"web server message finished"
);
}
}
catch
(
Exception
e
)
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