Mercurial Hosting > luan
comparison src/luan/webserver/Server.java @ 1176:79b1e9ffd0c0
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 12 Feb 2018 15:19:00 -0700 |
parents | d6d0bd05ad8c |
children | 83c8a5a47f70 |
comparison
equal
deleted
inserted
replaced
1175:d6d0bd05ad8c | 1176:79b1e9ffd0c0 |
---|---|
2 | 2 |
3 import java.io.IOException; | 3 import java.io.IOException; |
4 import java.net.Socket; | 4 import java.net.Socket; |
5 import java.net.ServerSocket; | 5 import java.net.ServerSocket; |
6 import java.net.InetAddress; | 6 import java.net.InetAddress; |
7 import java.net.UnknownHostException; | |
7 import java.util.concurrent.ExecutorService; | 8 import java.util.concurrent.ExecutorService; |
8 import java.util.concurrent.Executors; | 9 import java.util.concurrent.Executors; |
9 import java.util.concurrent.TimeUnit; | 10 import java.util.concurrent.TimeUnit; |
10 import org.slf4j.Logger; | 11 import org.slf4j.Logger; |
11 import org.slf4j.LoggerFactory; | 12 import org.slf4j.LoggerFactory; |
56 } catch(InterruptedException e) { | 57 } catch(InterruptedException e) { |
57 throw new RuntimeException(e); | 58 throw new RuntimeException(e); |
58 } | 59 } |
59 } | 60 } |
60 | 61 |
61 public static class Local extends Server { | 62 public static class ForAddress extends Server { |
62 public Local(int port,Handler handler) { | 63 private final InetAddress addr; |
64 | |
65 public ForAddress(InetAddress addr,int port,Handler handler) { | |
63 super(port,handler); | 66 super(port,handler); |
67 this.addr = addr; | |
68 } | |
69 | |
70 public ForAddress(String addrName,int port,Handler handler) throws UnknownHostException { | |
71 this(InetAddress.getByName(addrName),port,handler); | |
64 } | 72 } |
65 | 73 |
66 protected ServerSocket newServerSocket() throws IOException { | 74 protected ServerSocket newServerSocket() throws IOException { |
67 return new ServerSocket(port,0,InetAddress.getByName("127.0.0.1")); | 75 return new ServerSocket(port,0,addr); |
68 } | 76 } |
69 } | 77 } |
70 } | 78 } |