NanoHttpd는 하나의 소스 파일입니다 여기에 관련 클립 : 당신은 당신이 구성하여 원하는 효과를 얻을 수 있었던 것처럼
/**
* Constructs an HTTP server on given hostname andport.
*/
public NanoHTTPD(String hostname, int port) {
this.hostname = hostname;
this.myPort = port;
setTempFileManagerFactory(new DefaultTempFileManagerFactory());
setAsyncRunner(new DefaultAsyncRunner());
}
/**
* Start the server.
* @throws IOException if the socket is in use.
*/
public void start() throws IOException {
myServerSocket = new ServerSocket();
myServerSocket.bind((hostname != null) ? new InetSocketAddress(hostname, myPort) : new InetSocketAddress(myPort));
나는 여기에서 그것을 시도 할 수있는 위치에 아니에요하지만, 보이는 당신의 서버가 new NanoHTTPD("localhost",8080)
인 경우 - 바인드 작업이 localhost의 포트에 바인드됩니다 (와일드 카드 바인드를 사용하는 대신)
외부인이 액세스하지 못하도록 방화벽의 포트를 차단할 수 있습니다. – bmeding