From c36f336e6f294313cdab84352b108beea4607e48 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 26 Aug 2008 05:10:04 +0000 Subject: Update Trilead SSH-2 for Java from build 211 to build 213 --- lib/src/main/java/com/trilead/ssh2/Session.java | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'lib/src/main/java/com/trilead/ssh2/Session.java') diff --git a/lib/src/main/java/com/trilead/ssh2/Session.java b/lib/src/main/java/com/trilead/ssh2/Session.java index 098b3f1..4784537 100644 --- a/lib/src/main/java/com/trilead/ssh2/Session.java +++ b/lib/src/main/java/com/trilead/ssh2/Session.java @@ -18,7 +18,7 @@ import com.trilead.ssh2.channel.X11ServerData; * a session. However, multiple sessions can be active simultaneously. * * @author Christian Plattner, plattner@trilead.com - * @version $Id: Session.java,v 1.1 2007/10/15 12:49:56 cplattne Exp $ + * @version $Id: Session.java,v 1.2 2008/03/03 07:01:36 cplattne Exp $ */ public class Session { @@ -298,6 +298,32 @@ public class Session cm.requestSubSystem(cn, name); } + /** + * This method can be used to perform end-to-end session (i.e., SSH channel) + * testing. It sends a 'ping' message to the server and waits for the 'pong' + * from the server. + *

+ * Implementation details: this method sends a SSH_MSG_CHANNEL_REQUEST request + * ('trilead-ping') to the server and waits for the SSH_MSG_CHANNEL_FAILURE reply + * packet. + * + * @throws IOException in case of any problem or when the session is closed + */ + public void ping() throws IOException + { + synchronized (this) + { + /* + * The following is just a nicer error, we would catch it anyway + * later in the channel code + */ + if (flag_closed) + throw new IOException("This session is closed."); + } + + cm.requestChannelTrileadPing(cn); + } + public InputStream getStdout() { return cn.getStdoutStream(); -- cgit v1.2.3