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

write() public method

public write ( Packet packet ) : void
packet Packet
return void
		public void write(Packet packet) 
		{
			// System.Console.WriteLine("in_kex="+in_kex+" "+(packet.buffer.buffer[5]));
			while(in_kex)
			{
				byte command=packet.buffer.buffer[5];
				//System.Console.WriteLine("command: "+command);
				if(command==SSH_MSG_KEXINIT ||
					command==SSH_MSG_NEWKEYS ||
					command==SSH_MSG_KEXDH_INIT ||
					command==SSH_MSG_KEXDH_REPLY ||
					command==SSH_MSG_DISCONNECT ||
					command==SSH_MSG_KEX_DH_GEX_GROUP ||
					command==SSH_MSG_KEX_DH_GEX_INIT ||
					command==SSH_MSG_KEX_DH_GEX_REPLY ||
					command==SSH_MSG_KEX_DH_GEX_REQUEST)
				{				
					break;
				}
				try { System.Threading.Thread.Sleep(10); }
				catch(ThreadInterruptedException){};
			}
			_write(packet);
		}
		[System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.Synchronized)]

Same methods

Session::write ( Packet packet, Channel c, int length ) : void

Usage Example

Example #1
0
		public void request(Session session, Channel channel)
		{
			Buffer buf=new Buffer();
			Packet packet=new Packet(buf);

			bool reply=waitForReply();
			if(reply)
			{
				channel.reply=-1;
			}

			packet.reset();
			buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString(Util.getBytes("subsystem"));
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			buf.putString(Util.getBytes("sftp"));
			session.write(packet);

			if(reply)
			{
				while(channel.reply==-1)
				{
					try{System.Threading.Thread.Sleep(10);}
					catch//(Exception ee)
					{
					}
				}
				if(channel.reply==0)
				{
					throw new JSchException("failed to send sftp request");
				}
			}
		}
All Usage Examples Of Tamir.SharpSsh.jsch.Session::write