Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
肖健鑫
java_code1
Commits
40daf47f
Commit
40daf47f
authored
Nov 02, 2023
by
肖健鑫
Browse files
更新1.java
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
1.java
1.java
+27
-0
No files found.
1.java
0 → 100644
View file @
40daf47f
import
java.net.*
;
import
java.io.*
;
public
class
Client
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
String
host
=
"localhost"
;
int
port
=
12345
;
Socket
socket
=
new
Socket
(
host
,
port
);
System
.
out
.
println
(
"Connected to server"
);
PrintWriter
out
=
new
PrintWriter
(
socket
.
getOutputStream
(),
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
socket
.
getInputStream
()));
BufferedReader
stdIn
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
String
userInput
;
while
((
userInput
=
stdIn
.
readLine
())
!=
null
)
{
out
.
println
(
userInput
);
System
.
out
.
println
(
"Echo: "
+
in
.
readLine
());
}
out
.
close
();
in
.
close
();
stdIn
.
close
();
socket
.
close
();
}
}
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