|
12 | 12 | import edu.nju.http.util.Log; |
13 | 13 |
|
14 | 14 | import java.io.IOException; |
| 15 | +import java.net.InetAddress; |
15 | 16 | import java.net.InetSocketAddress; |
| 17 | +import java.net.InterfaceAddress; |
| 18 | +import java.net.NetworkInterface; |
| 19 | +import java.net.SocketException; |
16 | 20 | import java.net.StandardSocketOptions; |
17 | 21 | import java.nio.channels.AsynchronousServerSocketChannel; |
18 | 22 | import java.nio.channels.AsynchronousSocketChannel; |
19 | 23 | import java.nio.channels.CompletionHandler; |
| 24 | +import java.util.Arrays; |
20 | 25 | import java.util.HashMap; |
21 | 26 | import java.util.Map; |
22 | 27 | import java.util.concurrent.ExecutionException; |
@@ -45,6 +50,8 @@ public HttpServer(String hostName, int port) throws IOException { |
45 | 50 | this.handler = TargetHandler.getInstance(); |
46 | 51 | this.aServerSocket = AsynchronousServerSocketChannel.open(); |
47 | 52 | this.aServerSocket.bind(new InetSocketAddress(hostName, port)); |
| 53 | + Log.logServer("Server bound to " + this.aServerSocket.getLocalAddress().toString()); |
| 54 | + |
48 | 55 | this.globalHeaders = new HashMap<>(); |
49 | 56 |
|
50 | 57 | this.running = new Semaphore(0); |
@@ -168,7 +175,6 @@ private void handleSocket(AsynchronousSocketChannel socket, boolean keepAlive, i |
168 | 175 | keepAlive = false; |
169 | 176 | } |
170 | 177 |
|
171 | | - |
172 | 178 | // -------------------- 2. Handle the request and generate response -------------------- // |
173 | 179 | responseMessage = handler.handle(requestMessage); |
174 | 180 |
|
|
0 commit comments