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
肖健鑫
xiao-java
Compare Revisions
1c7f8449686c1b29a8678acbd2bf9d5b99d1fc60...deb4c79d8067cabee1565e1072360342c220150c
Commits (4)
Update .gitlab-ci.yml
· c4305bca
肖健鑫
authored
Oct 27, 2023
c4305bca
Update .gitlab-ci.yml
· 25ebcda3
肖健鑫
authored
Oct 27, 2023
25ebcda3
更新src/server.java
· 099caae6
肖健鑫
authored
Oct 27, 2023
099caae6
Merge branch 'test' into 'main'
· deb4c79d
肖健鑫
authored
Oct 27, 2023
Test See merge request
!1
deb4c79d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
src/server.java
src/server.java
+28
-0
No files found.
src/server.java
0 → 100644
View file @
deb4c79d
import
java.net.*
;
import
java.io.*
;
public
class
Server
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
int
port
=
12345
;
ServerSocket
serverSocket
=
new
ServerSocket
(
port
);
System
.
out
.
println
(
"Server started on port "
+
port
);
while
(
true
)
{
Socket
clientSocket
=
serverSocket
.
accept
();
System
.
out
.
println
(
"Client connected from "
+
clientSocket
.
getInetAddress
());
PrintWriter
out
=
new
PrintWriter
(
clientSocket
.
getOutputStream
(),
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
clientSocket
.
getInputStream
()));
String
inputLine
;
while
((
inputLine
=
in
.
readLine
())
!=
null
)
{
System
.
out
.
println
(
"Received message: "
+
inputLine
);
out
.
println
(
"Echo: "
+
inputLine
);
}
out
.
close
();
in
.
close
();
clientSocket
.
close
();
}
}
}