Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
server
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
9731050
server
Commits
82bf7bbe
Commit
82bf7bbe
authored
Jun 03, 2019
by
9731050
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server completed
parent
acfe0296
Pipeline
#685
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
Server.java
src/Server.java
+25
-5
No files found.
src/Server.java
View file @
82bf7bbe
import
java.io.IOException
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.net.SocketTimeoutException
;
import
java.util.ArrayList
;
public
class
Server
{
private
static
final
int
PORT
=
4321
;
private
ServerSocket
serverSocket
;
private
ArrayList
<
String
>
user
;
public
Server
()
throws
Exception
{
private
ArrayList
<
String
>
user
;
public
Server
()
throws
IOException
{
serverSocket
=
new
ServerSocket
(
PORT
);
user
=
new
ArrayList
<>();
user
=
new
ArrayList
<>();
serverSocket
.
setSoTimeout
(
1000
);
}
public
void
run
()
{
while
(
true
)
{
try
{
System
.
out
.
println
(
"Waiting for client on port "
+
serverSocket
.
getLocalPort
()
+
"..."
);
Socket
client
=
serverSocket
.
accept
();
ClientHandler
clientHandler
=
new
ClientHandler
(
client
);
client
.
close
();
}
catch
(
SocketTimeoutException
s
)
{
System
.
out
.
println
(
"Socket timed out!"
);
break
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
break
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
\ No newline at end of file
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