This project is read-only.

Help! Multiple VB.net questions

May 25, 2011 at 11:51 AM

Hi Oleg,

I'm experimenting a bit and I'm unable to solve two things in VB.net (most probably because of my very limited knowledge of the language):

1) what is the right syntax for port forwarding? could you kindly give me an example?

 

2) I have the following code (which connects just fine):

Dim cI = New PrivateKeyConnectionInfo(host, "user1", New PrivateKeyFile(File.OpenRead("c:/temp/user1.key")))

How can I see the AuthenticationBanner? Or any answer from the server?

 

3) Whenever I connect successfully with the above, if I execute "netstat -e" on the server (via PuTTY), I see "root" as the related user. Why not "user1"? client.username returns "users1"....

 

Thanks a lot for coping with me,

John

May 25, 2011 at 1:07 PM

Hi John,

 

1. Here is some example from my test cases, it still might not be perfect so any feedback in this area is welcome.

			using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
			{
				var port1 = client.AddForwardedPort<ForwardedPortLocal>("localhost", 8084, "www.renci.org", 80);
				port1.Exception += delegate(object sender, ExceptionEventArgs e)
				{
					Assert.Fail(e.Exception.ToString());
				};
				port1.Start();

				System.Threading.Tasks.Parallel.For(0, 100,
					(counter) =>
					{
						var start = DateTime.Now;
						var req = HttpWebRequest.Create("http://localhost:8084");
						using (var response = req.GetResponse())
						{

							var data = ReadStream(response.GetResponseStream());
							var end = DateTime.Now;

							Debug.WriteLine(string.Format("Request# {2}: Lenght: {0} Time: {1}", data.Length, (end - start), counter));
						}
					}
				);
			}

2. To get authentication banner you need to handle AuthenticationBanner event. It is available for all   ConnecgtionInfo based classes. Here short example:

            connectionInfo.AuthenticationBanner += delegate(object sender, AuthenticationBannerEventArgs e)
                                            {
                                                Console.WriteLine(e.BannerMessage);
                                            };

3. Please remind me to get you answer for number 3 next week as I am still on vacation and dont have access to investigate this issue.

 

Hope it helps,

 

Thanks,

Oleg

May 25, 2011 at 1:31 PM

Hi Oleg,

thanks for the very quick answer. Actually I was looking for examples in vb.net as I'm unable to translate the ones in c# provided in the help file... sorry for the misunderstanding!

Thanks again and enjoy the holidays!

John

May 25, 2011 at 2:48 PM

Hi John,

Sorry, I am not good in VB.NET so I hope someone here could help you to translate the examples.

 

Thanks,

Oleg

May 25, 2011 at 6:01 PM

Try using http://converter.telerik.com/ to convert examples  between c# and vb.net

Jun 6, 2011 at 10:12 AM
mladjenovic wrote:

Try using http://converter.telerik.com/ to convert examples  between c# and vb.net

Thanks, works great!

Jun 6, 2011 at 10:14 AM
olegkap wrote:

3. Please remind me to get you answer for number 3 next week as I am still on vacation and dont have access to investigate this issue.

Hi Oleg, just the reminder as requested. The issue was:

3) Whenever I connect successfully with the above, if I execute "netstat -e" on the server (via PuTTY), I see "root" as the related user. Why not "user1"? client.username returns "users1"....

 

Cheers John

Jun 6, 2011 at 1:22 PM

Hey John,

 

I guess I am not really familiar with this command.

When I run it I get a list of open internet connections and sockets.

Where do you see the related user? How can I find it?

 

Thanks,

Oleg