當前位置: 首頁>>代碼示例>>C#>>正文


C# Packet.reset方法代碼示例

本文整理匯總了C#中Tamir.SharpSsh.jsch.Packet.reset方法的典型用法代碼示例。如果您正苦於以下問題:C# Packet.reset方法的具體用法?C# Packet.reset怎麽用?C# Packet.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tamir.SharpSsh.jsch.Packet的用法示例。


在下文中一共展示了Packet.reset方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: run

 public override void run()
 {
     //    thread=Thread.currentThread();
     Buffer buf=new Buffer();
     Packet packet=new Packet(buf);
     int i=0;
     try
     {
         while(isConnected() &&
             thread!=null &&
             io!=null &&
             io.ins!=null)
                        {
                            i=io.ins.Read(buf.buffer, 14, buf.buffer.Length-14);
                            if(i==0)continue;
                            if(i==-1)
                            {
                                eof();
                                break;
                            }
                            if(_close)break;
                            packet.reset();
                            buf.putByte((byte)Session.SSH_MSG_CHANNEL_DATA);
                            buf.putInt(recipient);
                            buf.putInt(i);
                            buf.skip(i);
                            session.write(packet, this, i);
                        }
     }
     catch//(Exception e)
     {
         //System.out.println("ChannelShell.run: "+e);
     }
     thread=null;
 }
開發者ID:mzkabbani,項目名稱:cSharpProjects,代碼行數:35,代碼來源:ChannelShell.cs

示例2: request

		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");
				}
			}
		}
開發者ID:stux2000,項目名稱:dokan,代碼行數:34,代碼來源:RequestSftp.cs

示例3: request

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

			packet.reset();
			buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString( Util.getBytes("signal"));
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			buf.putString(Util.getBytes(signal));
			session.write(packet);
		}
開發者ID:MatanDavidCohen,項目名稱:StockAnalyzerWin,代碼行數:13,代碼來源:RequestSignal.cs

示例4: run

		public override void run()
		{
			//System.out.println(this+":run >");
			/*
				if(thread!=null){ return; }
				thread=Thread.currentThread();
			*/

			//    Buffer buf=new Buffer();
			Buffer buf=new Buffer(rmpsize);
			Packet packet=new Packet(buf);
			int i=-1;
			try
			{
				while(isConnected() &&
					thread!=null && 
					io!=null && 
					io.ins!=null)
				{
					i=io.ins.Read(buf.buffer, 
						14,    
						buf.buffer.Length-14
						-32 -20 // padding and mac
						);
					if(i==0)continue;
					if(i==-1)
					{
						eof();
						break;
					}
					if(_close)break;
					packet.reset();
					buf.WriteByte((byte)Session.SSH_MSG_CHANNEL_DATA);
					buf.WriteInt(recipient);
					buf.WriteInt(i);
					buf.Skip(i);
					session.write(packet, this, i);
				}
			}
			catch(Exception e)
			{
				Console.WriteLine("# ChannelSession.run");
				Console.WriteLine(e);
			}
			if(thread!=null)
			{
				//lock(thread){ System.Threading.Monitor.PulseAll(this);/*thread.notifyAll();*/ }
			}
			thread=null;
			//System.out.println(this+":run <");
		}
開發者ID:soywiz,項目名稱:csharputils,代碼行數:51,代碼來源:ChannelSession.cs

示例5: connect

        public override void connect()
        {
            try
            {
                Buffer buf=new Buffer(150);
                Packet packet=new Packet(buf);
                // send
                // byte   SSH_MSG_CHANNEL_OPEN(90)
                // string channel type         //
                // uint32 sender channel       // 0
                // uint32 initial window size  // 0x100000(65536)
                // uint32 maxmum packet size   // 0x4000(16384)

                packet.reset();
                buf.putByte((byte)90);
                buf.putString(Util.getBytes("direct-tcpip"));
                buf.putInt(id);
                buf.putInt(lwsize);
                buf.putInt(lmpsize);
                buf.putString(Util.getBytes(host));
                buf.putInt(port);
                buf.putString(Util.getBytes(originator_IP_address));
                buf.putInt(originator_port);
                session.write(packet);
                try
                {
                    while(this.getRecipient()==-1)
                    {
                        //Thread.sleep(500);
                        System.Threading.Thread.Sleep(10);
                    }
                }
                catch
                {
                }

                if(this.eof_remote)
                {      // failed to open
                    disconnect();
                    return;
                }

                thread=new Thread(new ThreadStart(this.run));
                thread.Start();
            }
            catch
            {
            }
        }
開發者ID:mzkabbani,項目名稱:cSharpProjects,代碼行數:49,代碼來源:ChannelDirectTCPIP.cs

示例6: request

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

			// send
			// byte     SSH_MSG_CHANNEL_REQUEST(98)
			// uint32 recipient channel
			// string request type       // "shell"
			// boolean want reply        // 0
			packet.reset();
			buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString(Util.getBytes("shell"));
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			session.write(packet);
		}
開發者ID:stux2000,項目名稱:dokan,代碼行數:17,代碼來源:RequestShell.cs

示例7: request

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

            packet.reset();
            buf.WriteByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
            buf.WriteInt(channel.getRecipient());
            buf.WriteString(Util.getBytes("pty-req"));
            buf.WriteByte((byte)(waitForReply() ? 1 : 0));
            buf.WriteString(Util.getBytes("vt100"));
            buf.WriteInt(80);
            buf.WriteInt(24);
            buf.WriteInt(640);
            buf.WriteInt(480);
            buf.WriteString(Util.getBytes(""));
            session.write(packet);
        }
開發者ID:yash0924,項目名稱:csharputils,代碼行數:18,代碼來源:RequestPtyReq.cs

示例8: request

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

			// byte      SSH_MSG_CHANNEL_REQUEST(98)
			// uint32 recipient channel
			// string request type        // "x11-req"
			// boolean want reply         // 0
			// boolean   single connection
			// string    x11 authentication protocol // "MIT-MAGIC-COOKIE-1".
			// string    x11 authentication cookie
			// uint32    x11 screen number
			packet.reset();
			buf.WriteByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.WriteInt(channel.getRecipient());
			buf.WriteString(Util.getBytes("x11-req"));
			buf.WriteByte((byte)(waitForReply() ? 1 : 0));
			buf.WriteByte((byte)0);
			buf.WriteString(Util.getBytes("MIT-MAGIC-COOKIE-1"));
			buf.WriteString(ChannelX11.getFakedCookie(session));
			buf.WriteInt(0);
			session.write(packet);
		}
開發者ID:soywiz,項目名稱:csharputils,代碼行數:24,代碼來源:RequestX11.cs

示例9: request

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

            //byte      SSH_MSG_CHANNEL_REQUEST
            //uint32    recipient_channel
            //string    "window-change"
            //boolean   FALSE
            //uint32    terminal width, columns
            //uint32    terminal height, rows
            //uint32    terminal width, pixels
            //uint32    terminal height, pixels
            packet.reset();
            buf.WriteByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
            buf.WriteInt(channel.getRecipient());
            buf.WriteString(Util.getBytes("window-change"));
            buf.WriteByte((byte)(waitForReply() ? 1 : 0));
            buf.WriteInt(width_columns);
            buf.WriteInt(height_rows);
            buf.WriteInt(width_pixels);
            buf.WriteInt(height_pixels);
            session.write(packet);
        }
開發者ID:yash0924,項目名稱:csharputils,代碼行數:24,代碼來源:RequestWindowChange.cs

示例10: sendIgnore

		public void sendIgnore() 
		{
			Buffer buf=new Buffer();
			Packet packet=new Packet(buf);
			packet.reset();
			buf.putByte((byte)SSH_MSG_IGNORE);
			write(packet);
		}
開發者ID:MatanDavidCohen,項目名稱:StockAnalyzerWin,代碼行數:8,代碼來源:Session.cs

示例11: setPortForwarding

		private void setPortForwarding(int rport) 
		{
			lock(grr)
			{
				Buffer buf=new Buffer(100); // ??
				Packet packet=new Packet(buf);

				try
				{
					// byte SSH_MSG_GLOBAL_REQUEST 80
					// String "tcpip-forward"
					// bool want_reply
					// String  address_to_bind
					// uint32  port number to bind
					packet.reset();
					buf.putByte((byte) SSH_MSG_GLOBAL_REQUEST);
					buf.putString( new String( "tcpip-forward" ).getBytes());
					//      buf.putByte((byte)0);
					buf.putByte((byte)1);
					buf.putString(new String("0.0.0.0").getBytes());
					buf.putInt(rport);
					write(packet);
				}
				catch(Exception e)
				{
					throw new JSchException(e.ToString());
				}

				grr.setThread(Thread.currentThread());
				try{ Thread.Sleep(10000);}
				catch(Exception e)
				{
				}
				int reply=grr.getReply();
				grr.setThread(null);
				if(reply==0)
				{
					throw new JSchException("remote port forwarding failed for listen port "+rport);
				}
			}
		}
開發者ID:MatanDavidCohen,項目名稱:StockAnalyzerWin,代碼行數:41,代碼來源:Session.cs

示例12: run

		public void run()
		{
			thread=this;

			byte[] foo;
			Buffer buf=new Buffer();
			Packet packet=new Packet(buf);
			int i=0;
			Channel channel;
			int[] start=new int[1];
			int[] length=new int[1];
			KeyExchange kex=null;

			try
			{
				while(_isConnected &&
					thread!=null)
				{
					buf=read(buf);
					int msgType=buf.buffer[5]&0xff;
					//      if(msgType!=94)
					//System.Console.WriteLine("read: 94 ? "+msgType);

					if(kex!=null && kex.getState()==msgType)
					{
						bool result=kex.next(buf);
						if(!result)
						{
							throw new JSchException("verify: "+result);
						}
						continue;
					}

					switch(msgType)
					{
						case SSH_MSG_KEXINIT:
							//System.Console.WriteLine("KEXINIT");
							kex=receive_kexinit(buf);
							break;

						case SSH_MSG_NEWKEYS:
							//System.Console.WriteLine("NEWKEYS");
							send_newkeys();
							receive_newkeys(buf, kex);
							kex=null;
							break;

						case SSH_MSG_CHANNEL_DATA:
							buf.getInt();
							buf.getByte();
							buf.getByte();
							i=buf.getInt();
							channel=Channel.getChannel(i, this);
							foo=buf.getString(start, length);
							if(channel==null)
							{
								break;
							}
							try
							{
								channel.write(foo, start[0], length[0]);
							}
							catch(Exception e)
							{
								//System.Console.WriteLine(e);
								try{channel.disconnect();}
								catch(Exception ee){}
								break;
							}
							int len=length[0];
							channel.setLocalWindowSize(channel.lwsize-len);
							if(channel.lwsize<channel.lwsize_max/2)
							{
								packet.reset();
								buf.putByte((byte)SSH_MSG_CHANNEL_WINDOW_ADJUST);
								buf.putInt(channel.getRecipient());
								buf.putInt(channel.lwsize_max-channel.lwsize);
								write(packet);
								channel.setLocalWindowSize(channel.lwsize_max);
							}
							break;

						case SSH_MSG_CHANNEL_EXTENDED_DATA:
							buf.getInt();
							buf.getShort();
							i=buf.getInt();
							channel=Channel.getChannel(i, this);
							buf.getInt();                   // data_type_code == 1
							foo=buf.getString(start, length);
							//System.Console.WriteLine("stderr: "+new String(foo,start[0],length[0]));
							if(channel==null)
							{
								break;
							}
							//channel.write(foo, start[0], length[0]);
							channel.write_ext(foo, start[0], length[0]);

							len=length[0];
							channel.setLocalWindowSize(channel.lwsize-len);
							if(channel.lwsize<channel.lwsize_max/2)
//.........這裏部分代碼省略.........
開發者ID:MatanDavidCohen,項目名稱:StockAnalyzerWin,代碼行數:101,代碼來源:Session.cs

示例13: setPortForwardingR

        public void setPortForwardingR(int rport, String host, int lport)
        {
            ChannelForwardedTCPIP.addPort(this, rport, host, lport);

            Buffer buf=new Buffer(100); // ??
            Packet packet=new Packet(buf);

            try
            {
                // byte SSH_MSG_GLOBAL_REQUEST 80
                // string "tcpip-forward"
                // bool want_reply
                // string  address_to_bind
                // uint32  port number to bind
                packet.reset();
                buf.putByte((byte) SSH_MSG_GLOBAL_REQUEST);
                buf.putString(Util.getBytes("tcpip-forward"));
                buf.putByte((byte)0);
                buf.putString(Util.getBytes("0.0.0.0"));
                buf.putInt(rport);
                write(packet);
            }
            catch(Exception e)
            {
                throw new JSchException(e.ToString());
            }
        }
開發者ID:mzkabbani,項目名稱:cSharpProjects,代碼行數:27,代碼來源:Session.cs

示例14: delPort

		internal static void delPort(Session session, int rport)
		{
			lock(pool)
			{
				Object[] foo=null;
				for(int i=0; i<pool.Count; i++)
				{
					Object[] bar=(Object[])(pool[i]);
					if (bar[0] != session) continue;
					if ((int)bar[1] != rport) continue;
					foo=bar;
					break;
				}
				if(foo==null)return;
				pool.Remove(foo);	
			}

			Buffer buf=new Buffer(100); // ??
			Packet packet=new Packet(buf);

			try
			{
				// byte SSH_MSG_GLOBAL_REQUEST 80
				// string "cancel-tcpip-forward"
				// boolean want_reply
				// string  address_to_bind (e.g. "127.0.0.1")
				// uint32  port number to bind
				packet.reset();
				buf.WriteByte((byte) 80/*SSH_MSG_GLOBAL_REQUEST*/);
				buf.WriteString(Encoding.UTF8.GetBytes("cancel-tcpip-forward"));
				buf.WriteByte((byte)0);
				buf.WriteString(Encoding.UTF8.GetBytes("0.0.0.0"));
				buf.WriteInt(rport);
				session.write(packet);
			}
			catch(Exception)
			{
				//    throw new JSchException(e.toString());
			}
		}
開發者ID:soywiz,項目名稱:csharputils,代碼行數:40,代碼來源:ChannelForwardedTCPIP.cs

示例15: close

		/*
		http://www1.ietf.org/internet-drafts/draft-ietf-secsh-connect-24.txt

	  5.3  Closing a Channel
		When a party will no longer send more data to a channel, it SHOULD
		 send SSH_MSG_CHANNEL_EOF.

				  byte      SSH_MSG_CHANNEL_EOF
				  uint32    recipient_channel

		No explicit response is sent to this message.  However, the
		 application may send EOF to whatever is at the other end of the
		channel.  Note that the channel remains open after this message, and
		 more data may still be sent In the other direction.  This message
		 does not consume window space and can be sent even if no window space
		 is available.

		   When either party wishes to terminate the channel, it sends
		   SSH_MSG_CHANNEL_CLOSE.  Upon receiving this message, a party MUST
		 send back a SSH_MSG_CHANNEL_CLOSE unless it has already sent this
		 message for the channel.  The channel is considered closed for a
		   party when it has both sent and received SSH_MSG_CHANNEL_CLOSE, and
		 the party may then reuse the channel number.  A party MAY send
		 SSH_MSG_CHANNEL_CLOSE without having sent or received
		 SSH_MSG_CHANNEL_EOF.

				  byte      SSH_MSG_CHANNEL_CLOSE
				  uint32    recipient_channel

		 This message does not consume window space and can be sent even if no
		 window space is available.

		 It is recommended that any data sent before this message is delivered
		   to the actual destination, if possible.
		*/

		internal virtual void close()
		{
			//System.Out.println("close!!!!");
			if(_close)return;
			_close=true;
			try
			{
				Buffer buf=new Buffer(100);
				Packet packet=new Packet(buf);
				packet.reset();
				buf.putByte((byte)Session.SSH_MSG_CHANNEL_CLOSE);
				buf.putInt(getRecipient());
				session.write(packet);
			}
			catch(Exception e)
			{
				//e.printStackTrace();
			}
		}
開發者ID:MatanDavidCohen,項目名稱:StockAnalyzerWin,代碼行數:55,代碼來源:Channel.cs


注:本文中的Tamir.SharpSsh.jsch.Packet.reset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。