SSHServer events in C# console application - WeOnlyDo Discussion board

SSHServer events in C# console application (General questions)

by gumma, Wednesday, February 02, 2005, 11:35 (7236 days ago)

Hello,

I am trying out evaluation version of SSHServer.
I need to wrap a proprietary protocol to secure communication.
It works fine in a winform application but not in console application... The server starts but no event is raised when a client tries to connect to the server. Have I missed something?

Source code is very simple:

static void Main(string[] args) {
// ...
sshServer = new wodSSHDClass();
sshServer.Connecting += new _IwodSSHDEvents_ConnectingEventHandler(sshServer_Connecting);
sshServer.Start(myPort);
// ...
}

private static void sshServer_Connecting(SSHUser user, ref SSHActions action) {
Console.WriteLine( Connection... );
}


Thanks

Re: SSHServer events in C# console application

by wodSupport, Wednesday, February 02, 2005, 13:28 (7236 days ago) @ gumma

Gumma,

I doubt it will work in console app at all. Problem is that component works in background. Console apps have main() function that is started and ends - which ends your app too. So, wodSSHServer is also destroyed.

On the other hand, if you try to call Thread.Sleep, you will also block wodSSHServer since it lives in the same thread.

You need to have Windows app that has message pump. You can make it not to show windows, but window must exist so your app runs idle for unlimited amount of time - at which time wodSSHServer also works.

Hope it helps.
Kreso

Re: SSHServer events in C# console application

by gumma, Wednesday, February 02, 2005, 15:04 (7236 days ago) @ wodSupport

Thank you for your prompt reply!
I well understood why it doesn't work but it is not a big problem for me. It was just a little confusing. I will purchase a license right now.