diff --git a/jpos/src/main/java/org/jpos/iso/BaseChannel.java b/jpos/src/main/java/org/jpos/iso/BaseChannel.java index 5791080b3e..e0a5c3235d 100644 --- a/jpos/src/main/java/org/jpos/iso/BaseChannel.java +++ b/jpos/src/main/java/org/jpos/iso/BaseChannel.java @@ -356,9 +356,17 @@ public void setTimeout (int timeout) throws SocketException { public int getTimeout () { return timeout; } + + /** + * sets timeout, and also keep alive + * @throws SocketException + */ protected void applyTimeout () throws SocketException { - if (timeout >= 0 && socket != null) - socket.setSoTimeout (timeout); + if (socket != null) { + socket.setKeepAlive(keepAlive); + if (timeout >= 0) + socket.setSoTimeout(timeout); + } } /** * Socket SO_LINGER option to use when closing the socket. @@ -390,8 +398,6 @@ public void connect () throws IOException { connect(newSocket (hosts, ports, evt)); } applyTimeout(); - if (socket != null) - socket.setKeepAlive (keepAlive); Logger.log (evt); setChanged(); notifyObservers();