windows service (wodFTPServer)
Hi,
I try to covert the wodFTPServer c# sample to windows service base,
But how can the FTP server event such as ftpd1_LoginPassword being captured in the service?
Thanks and Best regards
Gary
windows service
Hi Gary.
It's pretty much the same as any console app you would make. Make sure it doesn't end by itself, but after Start it called, there is message loop that would allow wodFTPServer's hidden window to process messages. Something like DoEvents in VB.
Can you try that?
Regards,
Jasmine.
windows service
Thanks, Jasmine
I am using C#, could you provide a simple example for that?
Thanks and Best regards
Gary
Hi Gary.
It's pretty much the same as any console app you would make. Make sure it doesn't end by itself, but after Start it called, there is message loop that would allow wodFTPServer's hidden window to process messages. Something like DoEvents in VB.
Can you try that?
Regards,
Jasmine.
windows service
Hi Gary.
I'm not that much of a C# expert, but I believe this link would help:
http://stackoverflow.com/questions/2443867/message-pump-in-net-windows-service
inside DLL.Init add startup code for wodFTPServer, and then message pump will continue to run.
Or, you could for a test add
while (true)
Sleep(10);
for a test in your C# code. This will allow messages to process I think but not nice approach.
Jasmine.
windows service
Hi Gary.
I'm not that much of a C# expert, but I believe this link would help:
http://stackoverflow.com/questions/2443867/message-pump-in-net-windows-service
inside DLL.Init add startup code for wodFTPServer, and then message pump will continue to run.
Or, you could for a test add
while (true)
Sleep(10);for a test in your C# code. This will allow messages to process I think but not nice approach.
Jasmine.
Thanks,Jasmine
The issue is the wodFTP event cannot be captured in the windows service.
I add the startup code for wodFTPServer in the dll init, and add the code you mentioned in onStart(), but still, the any wodFTP event cannot be captured when client try to connect.
Please help.
Thanks and Best regards
Gary
windows service
Hi Gary.
I just tried with regular console application that is easier to test. Following simple code works. Can you try it on your side, and then copy/paste to your service, and check if it works?
Jasmine
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
wodFTPDComLib.wodFTPDCom Ftp1;
Ftp1 = new wodFTPDComLib.wodFTPDCom();
Ftp1.Protocol = wodFTPDComLib.ProtocolsEnum.FTP;
Ftp1.LoginPassword += new wodFTPDComLib._IwodFTPDComEvents_LoginPasswordEventHandler(Ftp1_LoginPassword);
Ftp1.Start(21);
while (true)
Thread.Sleep(10);
}
static void Ftp1_LoginPassword(wodFTPDComLib.FtpUser User, string Login, string Password, ref wodFTPDComLib.FtpActions Action)
{
Action = wodFTPDComLib.FtpActions.Allow;
}
}
}