-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFEserver.java
More file actions
44 lines (37 loc) · 1.27 KB
/
Copy pathFEserver.java
File metadata and controls
44 lines (37 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.io.*;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
public class FEserver{
public static final String FILES_PATH = "CSNETWK MP\\CSNETWK MP\\serverFiles";
private ServerSocket serverSocket;
public static final String IP_ADDRESS = "127.0.0.1";
public static final int PORT = 12345;
public FEserver() {
try {
serverSocket = new ServerSocket();
serverSocket.bind(new InetSocketAddress(IP_ADDRESS, PORT));
acceptConnections();
} catch (IOException e) {
}
}
private void acceptConnections() throws IOException {
try {
while (true) {
Socket clientSocket = serverSocket.accept();
if (clientSocket.isConnected()) {
new Thread(() -> {
FEconnection client = new FEconnection(clientSocket);
client.handleCommands();
client.close();
}).start();
}
}
} catch (IOException e) {
// e.printStackTrace();
}
}
public static void main(String[] args) {
new FEserver();
}
}