diff options
author | ritchie <ritchie@gmx.at> | 2015-05-10 15:09:48 +0200 |
---|---|---|
committer | ritchie <ritchie@gmx.at> | 2015-05-10 15:09:48 +0200 |
commit | c88ba6d829b5c4430a5851c1c953e94ea93a692f (patch) | |
tree | 49fcdb62c7671cf1e42065a7dc2ddf55ace49767 /core | |
parent | 9c4e5f6d83e3a039caf3fec36372424e796e25e7 (diff) | |
download | nanohttpd-c88ba6d829b5c4430a5851c1c953e94ea93a692f.tar.gz |
#131 socket timeout configurable
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/fi/iki/elonen/NanoHTTPD.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java index 08b64c6..34cd213 100644 --- a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java +++ b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java @@ -1615,6 +1615,18 @@ public abstract class NanoHTTPD { * if the socket is in use. */ public void start() throws IOException { + start(NanoHTTPD.SOCKET_READ_TIMEOUT); + } + + /** + * Start the server. + * + * @param timeout + * timeout to use for socket connections. + * @throws IOException + * if the socket is in use. + */ + public void start(final int timeout) throws IOException { if (this.sslServerSocketFactory != null) { SSLServerSocket ss = (SSLServerSocket) this.sslServerSocketFactory.createServerSocket(); ss.setNeedClientAuth(false); @@ -1633,7 +1645,7 @@ public abstract class NanoHTTPD { try { final Socket finalAccept = NanoHTTPD.this.myServerSocket.accept(); registerConnection(finalAccept); - finalAccept.setSoTimeout(NanoHTTPD.SOCKET_READ_TIMEOUT); + finalAccept.setSoTimeout(timeout); final InputStream inputStream = finalAccept.getInputStream(); NanoHTTPD.this.asyncRunner.exec(new Runnable() { |