I want to log in to a FTP server permanently. I want to stay connected in the server even if the server time-out comes. But how? The InternetConnect function with the 7'th parameter as "INTERNET_FLAG_PASSIVE | INTERNET_FLAG_KEEP_CONNECTION" doesn't work in the way I want it. The server time-out still throws me out of the server.

My program needs to be stay connected in the server all the time, several days straight. And when the user does something (presses a button to write a file to the server) then I need to know if I am in the server or not (if the time-out has disconnected him). So, is there some function to get known if I am in the server or not?

(I have another (bad) solution in reserve too, but first I wanted to ask advice from you).

Thanks in advance.
Posted on 2003-01-18 06:57:10 by president
This should actually be posted in the "Network" forum and not here.
I have never bothered to use the Wininet api mainly because it sucks
when it comes to performance and control. Why dont you use the
real deal? (Winsock). IMO, The Wininet api is there when you need
some simple/small functions.

Server time-out:
When the ftp-server times-out a connection there is really nothing
good you can do to keep the connection. Other then some commands
wich are now not working with most servers. Some servers time-out
because of session-time-out or idle-time-out. The session-time-out
cant be stopped. However the idle-timeout can be stopped by e.g
jumping in and out of directories before the time-out occures.

Goto this site for information about Winsocks: www.madwizard.org
this topic has probably been talked about before so visit the network
section or use the search button.
Posted on 2003-01-18 07:09:42 by natas
But is there any special function to know if I am connected to a server or not?
Posted on 2003-01-18 09:41:49 by president
why do you need to keep connected for so long time anyway? it's a rather unpolite thing to do.
Posted on 2003-01-18 11:06:19 by f0dder
In the ftp protocol there is a keep alive command named "NOOP" which you can use to inform the server you're still active. It works for the purpose you want but if the server got a rule to skip this command and ignore it then it can and will still kick you and then there is nothing you can do about it. The only other way to make sure you are not kicked is making small data transfers so a timeout never happens but thats not a good way since it will eat your bandwidth.

// CyberHeg
Posted on 2003-01-19 01:53:06 by CyberHeg
The "NOOP" command is common knowledge to ftp-servers and are usually
always skipped because they dont want idlers on their ftp site. If there isnt
a session timeout then you could ofcourse just transfer a file limited to 1KbpSec.
You could start the transfer after a given time(10s before timeout maybe) and
then stop the transfer, wait and start the transfer again, in a loop. This wouldnt
eat anyones bandwidth, and youre connection would be kept-alive so to speak.
Posted on 2003-01-22 08:08:09 by natas