Ftp Error In Internetconnect Function
Contents |
Forum Visual Basic Programming Visual Basic .NET Problem with establishing FTP using InternetConnect If this is your internetconnect example first visit, be sure to check out the FAQ by clicking
Httpopenrequest
the link above. You may have to register or Login before you can post: click the register
Internetconnect Sftp
link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 2 of 2 Thread: Problem with
Internetconnect Https
establishing FTP using InternetConnect Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode August 28th, 2008,03:40 PM #1 tariqc View Profile View Forum Posts Junior Member Join Date Aug 2008 Posts 11 Problem with establishing FTP using InternetConnect Hello, I am having internet_flag_secure a problem using the InternetConnect API to establish an FTP connection. using getlasterror returns error 87 which is invalid parameter. I am not sure which parameter is invalid. I do believe the internet handle i am passing it is valid. heres the code m_hConnHandle = InternetConnect(m_hInetHandle, "172.21.1.2", 0, "", "", 1, 0, 0) Dim i As Int32 = Err.LastDllError() i is always = 87 I tried passing in 21 for the port but that does not help any help would be appreciated. Reply With Quote August 29th, 2008,12:47 AM #2 HanneSThEGreaT View Profile View Forum Posts CG Bouncer Power Poster Join Date Jul 2001 Location Sunny South Africa Posts 11,223 Re: Problem with establishing FTP using InternetConnect Welcome to the forums! You're in luck As I've been doing a lot with FTP these days. I've done this : Code: ''''''''''''''''''''''' ' API declarations
here for a quick overview of the site Help Center Detailed internetopen example c++ answers to any questions you might have Meta Discuss internet_service_ftp the workings and policies of this site About Us Learn more about Stack Overflow the internetconnecta company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss http://forums.codeguru.com/showthread.php?460105-Problem-with-establishing-FTP-using-InternetConnect Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR_IO_PENDING on FTP Asynchronous Operation [Wininet C++] up vote 0 down vote favorite I've recently been working on an application http://stackoverflow.com/questions/28706060/error-io-pending-on-ftp-asynchronous-operation-wininet-c that needs to establish an FTP connection with a server and download/upload files from it. For performance reasons, I would like to download multiple files at a time. For that reason I've tried to implement asynchronous operation on the Wininet API using the InternetOpen function along with the INTERNET_FLAG_ASYNC flag, as well as the InternetSetStatusCallback function. Here is a sample of my code, where I want to list all the files in the main directory of the remote server recursively: /*Global variables*/ HANDLE MayContinue=0; DWORD LatestResult=1; /*Prototypes*/ void CALLBACK CallbackFunction(HINTERNET,DWORD_PTR,DWORD,LPVOID,DWORD); //Iteration function called by main() void FTPIterate() { WIN32_FIND_DATAA data; HINTERNET Internet; INTERNET_STATUS_CALLBACK call; HINTERNET h_file; MayContinue = ::CreateEvent (NULL, FALSE, FALSE, NULL); iconnect=InternetOpen(NULL,INTERNET_OPEN_TYPE_PROXY,proxy_url,NULL,INTERNET_FLAG_ASYNC); call=InternetSetStatusCallback(iconnect,(INTERNET_STATUS_CALLBACK)CallbackFunction); while(f[FLAG_FTP_ITERATE]) { MayContinue = ::CreateEvent(NULL,FALSE,FALSE,NULL); InternetConnect(iconnect,ftp_url,INTERNET_DEFAULT_FTP_PORT,ftp_user,ftp_pass,INTERNET_SERVICE_FTP,NULL,LatestResult); WaitForSingleObject (MayContinue, INFINITE); server=(HINTERNET)LatestResult; printf("Server handle: %i\n",(int)server); printf("Server Error: %i\n",GetLastError()); SetLastError(0); MayContinue = ::CreateEvent(NULL,FALSE,FALSE,NULL); FtpFindFirstFile(server,ftp_base,&data,INTERNET_FLAG_NO_CACHE_WRITE,LatestResult); WaitForSingleObject(MayContinue,INFINITE); h_file=(HINTERNET)LatestResult; //do stuff printf("FindFirstFile handle: %i\n",(int)h_File); whil
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of http://stackoverflow.com/questions/5893757/unable-to-connect-to-ftp-server this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question http://msenthil.tripod.com/new/tipgn5.html x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ftp error Unable to connect to ftp server up vote 3 down vote favorite I'm trying to connect to an ftp server through a powerbuilder application using windows api functions. I manage to connect to the ftp server through Internet Explorer (so I don't think it's a permission problem) but the application fails for some unknown reason. String ls_Null, & ls_id Integer li_rc li_rc = ftp error in 1 IF Not InternetAutodial(AUTODIAL_FORCE_UNATTENDED, 0) THEN f_write_to_err_log('IMPORT Unable To Connect Internet - Dialup') li_rc = -1 ELSE SetNull(ls_Null) ls_id = "Care_Dsend" al_internet_handle = InternetOpen(ls_id, INTERNET_OPEN_TYPE_DIRECT, ls_Null, ls_Null, 0) IF al_internet_handle > 0 THEN al_ftp_connect_handle = InternetConnect(al_internet_handle, is_ftp_url, il_ftp_port, is_ftp_user, is_ftp_password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, al_ref) END IF END IF Return li_rc //al_internet_handle, al_ftp_connect_handle are by ref long parms //al_ref is a by ref unsignedlong parm //is_ftp_url, is_ftp_user, is_ftp_password are strings //il_ftp_port is long The function manages to return a handle from the InternetOpen api function, but returns 0 from the InternetConnect function. Any ideas? ftp connection powerbuilder share|improve this question asked May 5 '11 at 6:51 Guy 112114 I know nothing about powerbuilder, but do you need to specify a proxy? –Andrew Cooper May 5 '11 at 6:57 No, I don't. As mentioned in another comment, this script works in another application that was written a few years back, and I can't understand why it's not working now. –Guy May 8 '11 at 6:06 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted Ok, I found out what the problem
FTP commands, internet session should be opened using 'InternetOpen' function, then using the session handle, internet connection will be opened using 'InternetConnect' function which will return a connection handle that will be used in all other FTP commands. Following are the procedure and some constant declarations: ' Opens a HTTP/FTP session for a given site. Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _ (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _ ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _ ByVal lFlags As Long, ByVal lContext As Long) As Long ' Closes a single Internet handle or a subtree of Internet handles. Public Declare Function InternetCloseHandle Lib "wininet.dll" _ (ByVal hInet As Long) As Integer ' Initializes an application's use of the Win32 Internet functions Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _ (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _ ByVal sProxyBypass As String, ByVal lFlags As Long) As Long ' To down load a file from the FTP server Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _ (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _ ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _ ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean ' To up load a file from the FTP server Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _ (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _ ByVal lpszRemoteFile As String, _ ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean ' To change current directory in the remote server Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" _ (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean ' To get response information from the server Public Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" ( _ lpdwError As Long, _ ByVal lpszBuffer As String, _ lpdwBufferLength As Long) As Boolean ' Constant declarations Public Const ERROR_INTERNET_EXTENDED_ERROR = 12003 ' User agent constant. Public Const scUserAgent = "vb wininet" ' Use registry access settings. Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0 Public Const INTERNET_OPEN_TYPE_DIRECT = 1 Public Const INTERNET_OPEN_TYPE_PROXY = 3 Public Const INTERNET_INVALID_PORT_NUMBER = 0 Public Const FT