Explicitly disable socket linger

pull/184/head
M66B 5 years ago
parent d4f046eb02
commit ede1c4c817

@ -1025,15 +1025,24 @@ public class EmailService implements AutoCloseable {
} }
private static void configureSocketOptions(Socket socket) throws SocketException { private static void configureSocketOptions(Socket socket) throws SocketException {
int timeout = socket.getSoTimeout();
boolean keepAlive = socket.getKeepAlive();
int linger = socket.getSoLinger();
Log.i("Socket type=" + socket.getClass() + Log.i("Socket type=" + socket.getClass() +
" timeout=" + socket.getSoTimeout() + " timeout=" + timeout +
" linger=" + socket.getSoLinger() + " keep-alive=" + keepAlive +
" keepalive=" + socket.getKeepAlive()); " linger=" + linger);
if (socket.getKeepAlive()) { if (keepAlive) {
Log.e("Socket keep-alive"); Log.e("Socket keep-alive=" + keepAlive);
socket.setKeepAlive(false); socket.setKeepAlive(false);
} }
if (linger >= 0) {
Log.e("Socket linger=" + linger);
socket.setSoLinger(false, -1);
}
} }
class UntrustedException extends MessagingException { class UntrustedException extends MessagingException {

Loading…
Cancel
Save