AndroidAsync icon indicating copy to clipboard operation
AndroidAsync copied to clipboard

Binding to localhost

Open wngr opened this issue 7 years ago • 1 comments

It's currently not possible to have the AsyncHttpServer bind on specified interfaces, it always binds on all interfaces (0.0.0.0).

Looking at the code https://github.com/koush/AndroidAsync/blob/0e150f50d2a9bb068b18992040d6062dc2b88167/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServer.java#L228-L229 null is passed as the host parameter, which leads to the following block in AsyncServer https://github.com/koush/AndroidAsync/blob/0e150f50d2a9bb068b18992040d6062dc2b88167/AndroidAsync/src/com/koushikdutta/async/AsyncServer.java#L324-L327 instantiating a java.net.InetSocketAddress to listen on all interfaces. As far as I see, it would be just a matter of adding a method overload to AsyncHttpServer to expose the host parameter of AsyncServer.listen.

If there are no other obstacles, I'd be happy to contribute this.

wngr avatar Dec 06 '18 10:12 wngr

@koush what is your take on this?

wngr avatar Jan 09 '19 15:01 wngr