Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lab11
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731087
Lab11
Commits
ca0737d4
Commit
ca0737d4
authored
Jun 04, 2019
by
9731087
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Second edition: firstEdition + server sends a message too, and Client catches.
parent
06ffa244
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
ClientHandler.java
src/ClientHandler.java
+8
-0
Network.java
src/networking/Network.java
+3
-2
No files found.
src/ClientHandler.java
View file @
ca0737d4
...
@@ -19,6 +19,14 @@ public class ClientHandler implements Runnable {
...
@@ -19,6 +19,14 @@ public class ClientHandler implements Runnable {
//TODO: implement this method
//TODO: implement this method
// System.out.println("This is incoming message from Client: ");
// System.out.println("This is incoming message from Client: ");
System
.
out
.
println
(
message
);
System
.
out
.
println
(
message
);
PrintWriter
printWriter
=
null
;
try
{
printWriter
=
new
PrintWriter
(
new
OutputStreamWriter
(
client
.
getOutputStream
()));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
printWriter
.
println
(
message
);
printWriter
.
flush
();
}
}
@Override
@Override
...
...
src/networking/Network.java
View file @
ca0737d4
...
@@ -17,8 +17,9 @@ public class Network {
...
@@ -17,8 +17,9 @@ public class Network {
PrintWriter
printWriter
=
new
PrintWriter
(
new
OutputStreamWriter
(
socket
.
getOutputStream
()));
PrintWriter
printWriter
=
new
PrintWriter
(
new
OutputStreamWriter
(
socket
.
getOutputStream
()));
printWriter
.
println
(
"Hello from "
+
socket
.
getLocalSocketAddress
());
printWriter
.
println
(
"Hello from "
+
socket
.
getLocalSocketAddress
());
printWriter
.
flush
();
printWriter
.
flush
();
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
socket
.
getInputStream
()));
//socket.close();
System
.
out
.
println
(
bufferedReader
.
readLine
());
socket
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment