Tamir.SharpSsh.jsch.Session.setTimeout C# (CSharp) Method

setTimeout() public method

public setTimeout ( int foo ) : void
foo int
return void
		public void setTimeout(int foo)  
		{
			if(socket==null)
			{
				if(foo<0)
				{
					throw new JSchException("invalid timeout value");
				}
				this.timeout=foo;
				return;
			}
			try
			{
				socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, foo);
				socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, foo);

				timeout=foo;
			}
			catch(Exception e)
			{
				throw new JSchException(e.ToString());
			}
		}
		public String getServerVersion()

Usage Example

Example #1
0
        /// <summary>
        /// Constructs a new SSH stream.
        /// </summary>
        /// <param name="host">The hostname or IP address of the remote SSH machine</param>
        /// <param name="username">The name of the user connecting to the remote machine</param>
        /// <param name="password">The password of the user connecting to the remote machine</param>
        public SshStream(string host, string username, string password)
        {
            this.m_host = host;
            JSch jsch=new JSch();
            m_session=jsch.getSession(username, host, 22);
            m_session.setTimeout(9999);
            m_session.setPassword( password );

            Hashtable config=new Hashtable();
            config.Add("StrictHostKeyChecking", "no");
            m_session.setConfig(config);

            m_session.connect();
            m_channel=(ChannelShell)m_session.openChannel("shell");

            m_in	= m_channel.getInputStream();
            m_out	= m_channel.getOutputStream();

            m_channel.connect();
            m_channel.setPtySize(132, 132, 1024, 768);

            m_prompt = new Regex("\n");
            m_escapeCharPattern = "\\[[0-9;]*[^0-9;]";
        }