-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
26 lines (22 loc) · 853 Bytes
/
Server.java
File metadata and controls
26 lines (22 loc) · 853 Bytes
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
package httpserver;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
public class Server {
private final ServerSocket serverSocket;
private final AppConfig appConfig;
public Server(ServerSocket serverSocket, AppConfig appConfig) {
this.serverSocket = serverSocket;
this.appConfig = appConfig;
}
public void acceptConnection(ExecutorService executorService, SocketHandlerFactory socketHandlerFactory) {
try {
Socket clientSocket = serverSocket.accept();
SocketHandler socketHandler = socketHandlerFactory.newSocketHandler(appConfig, clientSocket);
executorService.submit(socketHandler);
} catch (IOException e) {
appConfig.getLogger().log(e.toString());
}
}
}