FTP Client code

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TerryHough.

Does anyone have any working FTP client code?

TIA
Terry
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Hi Terry,

You will have some answers searching ftp with quoted 'archive' checkbox in this forum.

BTW, I place here a sample code I made and cannot find again in tricks'n tips.

It is not perfect but may help you to start.

Come back with questions if you have any more to learn / understand.

KRgrds

Code: Select all

;
; Designed by FRW 20020603
; Updates 20021122
;
; WRP_Nasca_FTP-t is a test ftp client for testing and training purpose.
;
; It is designed from original WRP_Nasca_FTP with a reduced user interface template.
;
; See in line comments for any needed help.
;

#MAX_PATH = 260

#FILE_ATTRIBUTE_READONLY = 1
#FILE_ATTRIBUTE_HIDDEN = 2
#FILE_ATTRIBUTE_SYSTEM = 4
#FILE_ATTRIBUTE_DIRECTORY = 16
#FILE_ATTRIBUTE_ARCHIVE = 32
#FILE_ATTRIBUTE_NORMAL = 128
#FILE_ATTRIBUTE_TEMPORARY = 256
#FILE_ATTRIBUTE_COMPRESSED = 2048

#NO_ERROR = 0
#ERROR_NO_MORE_FILES = 18
#ERROR_INTERNET_EXTENDED_ERROR = 12003

#FTP_TRANSFER_TYPE_BINARY = 2
#INTERNET_OPEN_TYPE_DIRECT = 1
#INTERNET_DEFAULT_FTP_PORT = 21
#INTERNET_SERVICE_FTP = 1

#Main_Window = 92

#Gadget_String_Input = 11
#Gadget_OK_Button = 12
#Gadget_Quit_Button = 13
#Gadget_Text_Output = 14
#Gadget_Help = 15

Structure PB_FIND_DATA
      FileAttributes.l
      CreationTimeL.l
      CreationTimeH.l
      LastAccessTimeL.l
      LastAccessTimeH.l
      LastWriteTimeL.l
      LastWriteTimeH.l
      FileSizeHigh.l
      FileSizeLow.l
      OID.l
      FileName.s[#MAX_PATH]
EndStructure

DefType.WIN32_FIND_DATA PB_FIND_DATA


hInternetSession.l
hInternetConnect.l
hMainWindow.l

UsedFont.s
UsedFontSize.s
EOL.s

*PathBuff = AllocateMemory(0, 2500, 0)

Global EOL, UsedFont, UsedFontSize, hInternetSession, hInternetConnect, hMainWindow, PB_FIND_DATA

;
; Procedures
;
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents 
  Select Message
    Case #WM_SIZE
      WindowXSize = WindowWidth()
      WindowYSize = WindowHeight()
      ResizeGadget(#Gadget_String_Input, 10, 10, WindowXSize - 20, 20)
      ResizeGadget(#Gadget_Text_Output, 10, 70, WindowXSize - 20, WindowYSize - 90)
      ResizeGadget(#Gadget_OK_Button, WindowXSize - 110, 40, 40, 20)
      ResizeGadget(#Gadget_Quit_Button, WindowXSize  - 60, 40, 40, 20)
  EndSelect
  ProcedureReturn Result 
EndProcedure 


;
; Main starts here
;

BytesRead.w
BytesToRead.w

hGetFile.l
hCurrentDirectory.l
hResponse.l

i.l
iu.l
WindowXSize.l
WindowYSize.l
ScreenWidth.l
ScreenHeight.l
WindowXstart.l
WindowYStart.l
FontPointer.l
LSFileAttributes.l
LSCreationTimeL.l
LSCreationTimeH.l
LSLastAccessTimeL.l
LSLastAccessTimeH.l
LSLastWriteTimeL.l
LSLastWriteTimeH.l
LSFileSizeHigh.l
LSFileSizeLow.l
LSOID.l
LShFindFile.l
NItems.l

Name.s
UserName.s
Password.s
Path.s
SubPath.s
File.s
File1.s
File2.s
LSFileName.s
LSTempFileName.s
LSTempFA.s
LSTempFA1.s
LSTempFA2.s
LSTempFA3.s
LSTempFA4.s
LSTempFA5.s
LSTempFA6.s
LSTempFA7.s
LSTempFA8.s
LSTempFileSize.s
ServiceMessage.s
InternetReadFileName.s
FTPUserCommand.s
FTPUserArgs.s
CommandLine.s
SBuff.s
ServiceMessage.s
CharacterSet.s
ServiceMessage.s

;
; General purpose initalization
;
  EOL = Chr(13) + Chr(10)

  ServiceMessage.s = ""

 
  Name.s = ""
  UserName.s = ""
  Password.s = ""
  SubPath.s = ""
  FTPUserCommand.s = ""
  FTPUserArgs.s = ""
  CommandLine.s = ""

  BytesToRead = 10000

  ServiceMessage.s = ""
  Quit = #FALSE
  
  WindowXSize = 480
  WindowYSize = 360
  WindowXStart = (GetSystemMetrics_(#SM_CXSCREEN) - WindowXSize) / 2
  WindowYStart = (GetSystemMetrics_(#SM_CYSCREEN) - WindowYSize) / 2
  FTPSession = 0
  
  ;
  ; Create and use the Main window
  ;
  hMainWindow = OpenWindow(#Main_Window, WindowXStart, WindowYStart, WindowXSize, WindowYSize, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_BorderLess | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, "WRP - Nasca FTP Client - Main Window")
  If hMainWindow
      AddKeyboardShortcut(#Main_Window, #PB_Shortcut_Return, #Gadget_OK_Button)
      StartDrawing(WindowOutput())
      FrontColor(255, 255, 180)
      BackColor(40, 40, 80)
      UsedFont = "Courier New"
      UsedFontSize = "8"
      Result = LoadFont(0, UsedFont, Val(UsedFontSize))
      UseFont(0)
      FontID = FontID()
      Result = CreateGadgetList(WindowID())
      SetGadgetFont(FontID())
      StringGadget(#Gadget_String_Input, 10, 10, WindowXSize - 20, 20, "")                   ; command input string box
      StringGadget (#Gadget_Text_Output, 10, 70, WindowXSize - 20, WindowYSize - 90, "open a connection first using open server user:pass", #PB_String_Multiline | #ES_AUTOVSCROLL | #WS_VSCROLL | #WS_HSCROLL)      ; display output text box
      DrawingFont(FontID)
      
      ButtonGadget (#Gadget_OK_Button, WindowXSize - 110, 40, 40, 20, "OK")
      ButtonGadget (#Gadget_Quit_Button, WindowXSize  - 60, 40, 40, 20, "Quit")
      StopDrawing()
      
      SetWindowCallback(@MyWindowCallBack())
      
      ;
      ; Preparing the drawing window context
      ;
      Result = CreateGadgetList(WindowID())
      
      Repeat
        ServiceMessage = ""
        WEvent = WaitWindowEvent()
        WIDEvent = EventWindowID()
        GEvent = EventGadgetID()
        ;
        ; 3 ways to stop and quit : Close the window / Key in ESC key / key in quit command in command line (see below)
        ;
        If WEvent = #PB_EventCloseWindow And WIDEvent = #Main_Window
            Quit = #TRUE
        EndIf
        
        ;
        ; Keys
        ;
        If EventType() = #PB_EventType_ReturnKey ; Return key has been pushed
            CommandLine = GetGadgetText(#Gadget_String_Input) + " "
            iu = FindString(CommandLine, " ", 1)
            If iu = 0
                FTPUserCommand = CommandLine
                FTPUserArgs = ""
              Else
                FTPUserCommand = Mid(LCase(LTrim(RTrim(CommandLine))), 1, iu -1)
                FTPUserArgs = LTrim(RTrim(Mid(CommandLine, iu, Len(CommandLine) - iu + 1)))
            EndIf
            SetGadgetText(#Gadget_String_Input, "")
        EndIf
        ;
        ; Gadget events
        ;
        Select GEvent                            ; If Gadgets were activated
          Case #Gadget_OK_Button                                   ; OK button
            CommandLine = GetGadgetText(#Gadget_String_Input) + " "
            iu = FindString(CommandLine, " ", 1)
            If iu = 0
                FTPUserCommand = CommandLine
                FTPUserArgs = ""
              Else
                FTPUserCommand = LCase(LTrim(RTrim(Mid(CommandLine, 1, iu -1))))
                FTPUserArgs = LTrim(RTrim(Mid(CommandLine, iu, Len(CommandLine) - iu + 1)))
            EndIf
            SetGadgetText(#Gadget_String_Input, "")
          Case #Gadget_Quit_Button                                   ; Quit button
            Quit = #TRUE
          Default
        EndSelect
        If FTPSession = 1
            ;
            ; Following commands are only possible when an FTP session exists
            ;
            ; cd                                change remote working directory
            ; delete file                       delete remote file
            ; dir [path]                        list remote directory
            ; get file                          download file from server to client
            ; ls [path]                         list remote directory
            ; mkdir [path]                      create a new remote directory
            ; put file                          upload file from client to server
            ; pwd                               print remote working directory
            ; recv file                         download file from server to client
            ; rename file1 file2                rename remote file1 into file2
            ; rmdir [path]                      remove remote directory
            ; send file                         upload file from client to server
            ; 

            ;
            ; If FTPUserCommand was generated through events
            ;
            If FTPUserCommand  ""
                ServiceMessage = FTPUserCommand + " " + FTPUserArgs ; Default ServiceMessage
                Select FTPUserCommand
                  Case "cd"                            ; change working directory on server
                    If FtpSetCurrentDirectory_(hInternetConnect, @FTPUserArgs)
                      Else
                        ServiceMessage = "FTPSetCurrentDirectory_ error : " + Str(GetLastError_())
                    EndIf
                  Case "delete"                        ; delete file
                    If FtpDeleteFile_(hInternetConnect, FTPUserArgs)
                      Else
                        ServiceMessage = "FTPDeletFile_ error : " + Str(GetLastError_())
                    EndIf
                  Case "dir"                           ; dir                         = ls
                    Goto ls_command
get_command:          Case "get"                           ; get file from server
                    If FtpGetFile_(hInternetConnect, FTPUserArgs, FTPUserArgs, 0, #FILE_ATTRIBUTE_NORMAL, #FTP_TRANSFER_TYPE_BINARY, 0)
                      Else
                        ServiceMessage = "FTPGetFile_ error : " + Str(GetLastError_())
                    EndIf
                  Case "help"
                      Goto help_command
ls_command:       Case "ls"                            ; ls edit the content of the current directory
                    NItems = 0
                    SetGadgetText(#Gadget_Text_Output, "")
                    LSFileName = FTPUserArgs
                    ;
                    ; The process consists in FindFirstFile to fetch the first item and a loop
                    ; with FindNextFile.
                    ;
                    ; Each item has parameters stored in WIN32_FIND_DATA accessible with
                    ; PB_FIND_DATA by structure equivalence. As far as items are found the loop
                    ; continues until a ERROR_NO_MORE_FILES error code. It is then necessary 
                    ; to close the handle opened with FindFirstFile.
                    ;
                    ServiceMessage = ""
                    ServiceMessage = ""
                    LShFindFile = FtpFindFirstFile_(hInternetConnect, LSFileName + "*", @PB_FIND_DATA, 0, 0)
                    If LShFindFile
                        NItems = NItems + 1
                        While GetLastError_()  #ERROR_NO_MORE_FILES And GetLastError_()  #ERROR_FILE_NOT_FOUND
                          ;
                          ; Loads the stored file information in local specific variables
                          ;
                          LSFileAttributes  = PeekL( @PB_FIND_DATA      )
                          LSCreationTimeL   = PeekL( @PB_FIND_DATA + 4  )
                          LSCreationTimeH   = PeekL( @PB_FIND_DATA + 8  )
                          LSLastAccessTimeL = PeekL( @PB_FIND_DATA + 12 )
                          LSLastAccessTimeH = PeekL( @PB_FIND_DATA + 16 )
                          LSLastWriteTimeL  = PeekL( @PB_FIND_DATA + 20 )
                          LSLastWriteTimeH  = PeekL( @PB_FIND_DATA + 24 )
                          LSFileSizeHigh    = PeekL( @PB_FIND_DATA + 28 )
                          LSFileSizeLow     = PeekL( @PB_FIND_DATA + 32 )
                          LSOID             = PeekL( @PB_FIND_DATA + 36 )
                          LSFileName        = PeekS( @PB_FIND_DATA + 44 )
                          ;
                          ; Generates a 40 characters file name just for the listing        
                          ;
                          LSTempFileName = LSFileName
                          If Len(LSTempFileName)  18
                            ServiceMessage = "ls error" + EOL + Str(GetLastError_())
                        EndIf
                    EndIf
                  Case "mkdir"                         ; mkdir create a new directory entry point in the current working directory
                    If FtpCreateDirectory_(hInternetConnect, FTPUserArgs)
                      Else
                        ServiceMessage = "FTPCreateDirectory_ error : " + Str(GetLastError_())
                    EndIf
                  Case "put"                           ; put file to server
put_command:            If FtpPutFile_(hInternetConnect, FTPUserArgs, FTPUserArgs, 0, 0)
                      Else
                        ServiceMessage = "FTPPutFile_ error : " + Str(GetLastError_())
                    EndIf
                  Case"pwd"                            ; print the current server working directory
                    Length = #MAX_PATH
                    If FtpGetCurrentDirectory_(hInternetConnect, *PathBuff, @Length)
                        Path = PeekS(*PathBuff)
                        ServiceMessage = "pwd " + Path
                      Else
                        ServiceMessage = "FTPGetCurrentDirectory_ error : " + Str(GetLastError_())
                    EndIf
                  Case "recv"                          ; get file from server        = get
                    Goto get_command
                  Case "rename"                        ; rename file1 into file2
                    iu = FindString(FTPUserArgs, " ", 1)
                    File1 = LTrim(RTrim(Mid(FTPUserArgs, 1, iu -1)))
                    File2 = LTrim(RTrim(Mid(FTPUserArgs, iu + 1, Len(FTPUserArgs) - iu - 1 + 1)))
                    If FtpRenameFile_(hInternetConnect, File1, File2)
                        ServiceMessage = "rename " + File1 + " " + File2
                      Else
                        ServiceMessage = "FTPRenameFile_ error : " + Str(GetLastError_())
                    EndIf
                  Case "rmdir"                         ; rmdir delete a empty directory entry point in the current working directory
                    If FtpRemoveDirectory_(hInternetConnect, FTPUserArgs)
                      Else
                        ServiceMessage = "FTPRemoveDirectory_ error : " + Str(GetLastError_())
                    EndIf
                  Case "send"                          ; put file to server          = put
                    Goto put_command
                  Default
                EndSelect
                ;
                ; I put this delay because I experienced much stability problems without ! Don't know why
                ;
                FTPUserCommand = ""
                FTPUserArgs = ""
            EndIf
          Else
            ;
            ; Some commands are allowed if no connection exists
            ; This is especially the case for giving connection parameters !
            ;
            ; Enabled commands at this level are :
            ;
            ; *** top level, connection and session parameters and commands ***
            ;
            ; open name [user[:password]]       open a FTP session to server name with optional user and password account parameters
            ; quit                              close the FTP session and quit the program
            ;
            ; *** other management commands
            ;
            ; help
            ; show
            ;
            Select FTPUserCommand
              Case "open"
                iu1 = FindString(FTPUserArgs, " ", 1)
                iu2 = FindString(FTPUserArgs, ":", 1)
                If iu1  0
                    If iu2  0
                        Name = Mid(FTPUserArgs, 1, iu1 - 1)
                        UserName = Mid(FTPUserArgs, iu1 + 1, iu2 - iu1 -1)
                        Password = Mid(FTPUserArgs, iu2 + 1, Len(FTPUserArgs) - iu2 - 1 + 1)
                      Else
                        Name = Mid(FTPUserArgs, 1, iU1 - 1)
                        UserName = Mid(FTPUserArgs, iu1 + 1 , Len(FTPUserArgs) - iu1 - 1 + 1)
                    EndIf
                  Else
                    Name = FTPUserArgs
                EndIf
                hInternetSession.l = InternetOpen_("FTP", #INTERNET_OPEN_TYPE_DIRECT, "", "", 0)
                If hInternetSession  0
                    ServiceMessage = "Opened network" + EOL
                    ;
                    ; Connects to an FTP server
                    ;
                    hInternetConnect.l = InternetConnect_(hInternetSession.l, Name, #INTERNET_DEFAULT_FTP_PORT, UserName, Password, #INTERNET_SERVICE_FTP, 0, 0)
                    If hInternetConnect  0
                        ServiceMessage = ServiceMessage + "Opened session on " + Name + " " + Username + ":" + Password + EOL
                        FTPSession = 1
                      Else
                        ServiceMessage = "InternetConnect_ failed"
                    EndIf
                  Else
                    ServiceMessage = "InternetOpen_ failed"
                EndIf
              Case "quit"                          ; quit closes the session and the program
                If hInternetSession
                    If hInternetConnect
                        InternetCloseHandle_(hInternetConnect)
                        hInternetConnect = #FALSE
                      Else
                        ServiceMessage = "No connection to close"
                    EndIf
                    InternetCloseHandle_(hInternetSession)
                    hInternetSession = #FALSE
                  Else
                    ServiceMessage = "No Internet access to close"
                EndIf
                FTPSession = 0
                Quit = #TRUE
              Case "help"
                ;
                ; Prepare the Help window context
                ;
help_command:   ServiceMessage = ""
                Select FTPUserArgs
                  Case ""
                    ServiceMessage = ServiceMessage + "To start you must open a connection using :" + EOL + EOL
                    ServiceMessage = ServiceMessage + "open Server Username:password" + EOL + EOL
                    ServiceMessage = ServiceMessage + ". bye           =>  quit" + EOL
                    ServiceMessage = ServiceMessage + ". cd path                  change directory" + EOL
                    ServiceMessage = ServiceMessage + ". debug                    set / unset internal Debug" + EOL
                    ServiceMessage = ServiceMessage + ". delete file              delete a file" + EOL
                    ServiceMessage = ServiceMessage + ". dir path/file =>  ls" + EOL
                    ServiceMessage = ServiceMessage + ". get file                 download a file from server to client" + EOL
                    ServiceMessage = ServiceMessage + ". help                     display this information" + EOL
                    ServiceMessage = ServiceMessage + ". ls path/file             list a directory/file (accepts generic characters)" + EOL
                    ServiceMessage = ServiceMessage + ". quit                     end of session" + EOL
                    ServiceMessage = ServiceMessage + ". put file                 upload a file from client to server" + EOL
                    ServiceMessage = ServiceMessage + ". recv          =>   get" + EOL
                    ServiceMessage = ServiceMessage + ". rename file1 file2       change the name file1 into file2" + EOL
                    ServiceMessage = ServiceMessage + ". rmdir path               remove a directory" + EOL
                    ServiceMessage = ServiceMessage + ". send          =>  put"
                  Case "bye"
                    ServiceMessage = ServiceMessage + "bye : close the ftp session" + EOL + EOL
                    ServiceMessage = ServiceMessage + "bye is equivalent to quit" + EOL
                  Case "cd"
                    ServiceMessage = ServiceMessage + "cd path : change the current working directory on the server" + EOL
                  Case "debug"
                    ServiceMessage = ServiceMessage + "debug : opens a text console to display more processing details" + EOL
                  Case "delete"
                    ServiceMessage = ServiceMessage + "delete file : removes the named file from the server" + EOL
                  Case "dir"
                    ServiceMessage = ServiceMessage + "dir [path/filemask] : list the content of [path/filemask]" + EOL + EOL
                    ServiceMessage = ServiceMessage + "[path/filemask] can be any path/file access including meta characters" + EOL
                    ServiceMessage = ServiceMessage + "dir is equivalent to ls" + EOL
                  Case "get"
                    ServiceMessage = ServiceMessage + "get file : transmit file from server to client" + EOL
                  Case "help"
                    ServiceMessage = ServiceMessage + "help [command] : help gives the general help information." + EOL + EOL
                    ServiceMessage = ServiceMessage + "Giving a command name in argument gives a more detailed help" + EOL
                    ServiceMessage = ServiceMessage + "for the given command" + EOL
                  Case "ls"
                    ServiceMessage = ServiceMessage + "ls [path/filemask] : list the content of [path/filemask]" + EOL + EOL
                    ServiceMessage = ServiceMessage + "[path/filemask] can be any path/file access including meta characters" + EOL
                  Case "quit"
                    ServiceMessage = ServiceMessage + "quit : close the ftp session" + EOL
                  Case "put"
                    ServiceMessage = ServiceMessage + "put file : transmit file from client to server" + EOL
                  Case "recv"
                    ServiceMessage = ServiceMessage + "recv file : transmit file from server to client" + EOL + EOL
                    ServiceMessage = ServiceMessage + "recv is equivalent to get" + EOL
                  Case "rename"
                    ServiceMessage = ServiceMessage + "rename file1 file2 : change filename file1 to file2" + EOL
                  Case "rmdir"
                    ServiceMessage = ServiceMessage + "rmdir directory : remove directory" + EOL
                  Case "send"
                    ServiceMessage = ServiceMessage + "send file : transmit file from client to server" + EOL + EOL
                    ServiceMessage = ServiceMessage + "send is equivalent to put" + EOL
                  Default
                    ServiceMessage = ServiceMessage + "Check functionalities using : help" + EOL
                EndSelect
                FTPUserCommand = ""
                FTPUserArgs = ""
                SetGadgetText(#Gadget_Text_Output, ServiceMessage)
              Case "show"
                ServiceMessage = ""
                ServiceMessage = ""
                ServiceMessage = ServiceMessage + "Server           : " + Name      + EOL
                ServiceMessage = ServiceMessage + "Username         : " + UserName  + EOL
                ServiceMessage = ServiceMessage + "Password         : " + Password  + EOL
                ServiceMessage = ServiceMessage + EOL
                ServiceMessage = ServiceMessage + "FTPSession       : " + Str(FTPSession) + EOL
                ServiceMessage = ServiceMessage + "hInternetSession : " + Str(hInternetSession) + EOL
                ServiceMessage = ServiceMessage + "hInternetConnect : " + Str(hInternetConnect) + EOL
                ServiceMessage = ServiceMessage + EOL
                ServiceMessage = ServiceMessage + "Font             : " + UsedFont + EOL
                ServiceMessage = ServiceMessage + "Font size        : " + UsedFontSize + EOL
                SetGadgetText(#Gadget_Text_Output, ServiceMessage)
              Default
            EndSelect
        EndIf
        If ServiceMessage  ""
            SetGadgetText(#Gadget_Text_Output, ServiceMessage)
        EndIf
      Until Quit
    Else
  EndIf ; Close hMainWindow
      
  If InternalDebug > 0
      CloseConsole()
  EndIf
  
  If hInternetConnect
      InternetCloseHandle_(hInternetConnect)
  EndIf
  If hInternetSession
      InternetCloseHandle_(hInternetSession)
  EndIf
End
Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TerryHough.
Originally posted by fweil
BTW, I place here a sample code I made and cannot find again in tricks'n tips.

It is not perfect but may help you to start.

Francois Weil
Thanks for your response and I will study the code you posted. I
thought I had seen something here before but sure couldn't fint it
yesterday.

Terry
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TerryHough.

Thanks Francois!

That got me going pretty well.

I have two problems remaining to solve. I have to send the FTP host
a host specific command rather than one of the standard FTP commands
supported by WinAPI or your code. Still scratching my head on that
one.

The other is that after I successfully download a file, I must
archive it on the host (move it to a different directory). I haven't
spent much time on that yet, and it may be possible that the Rename
function will handle it if it allows changing the directory too.

Thanks again for your suggestions and code.

Terry
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Maybe you can go back to RFC texts for sending custom commands to your host. AFAIK the way to manage non regular verbs using ftp is described in a RFC.

Rgrds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TerryHough.

Any idea how to connect in PASV mode?

Apparently the host requires this mode.

Thanks,
Terry

Edited later:
Found how to do this
#INTERNET_SERVICE_PASSIVE = $8000000
.
.
hInternetConnect.l = InternetConnect_(hInternetSession.l, IPAddress, Val(Port), UserName, Password, #INTERNET_SERVICE_FTP, #INTERNET_SERVICE_PASSIVE, 0)

At least it is now working for me.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TerryHough.

Thanks to fweil, I am nearing completion of the FTP program I needed.
His code example helped tremendously.

I am struggling with one problem.

When I attempt to connect to the Internet (and a current connection doesn't already exist), the program uses the DUN entry described as "default" (when set properly) and dials out and connects.

Here is my problem... When the program finishes and the disconnect command is issued, the modem connection is left active.

If my program created the connection, I need to tell the modem to hangup, but I don't know how to do that OR even how to tell if my program caused the modem to create the dialup connection.

Any ideas or pointers will be appreciated.

HELP! I'm still struggling with getting the modem to drop the connection. Any ideas appreciated.


TIA
Terry
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TerryHough.
Originally posted by TerryHough

Thanks to fweil, I am nearing completion of the FTP program I needed.
His code example helped tremendously.

I am struggling with one problem.

When I attempt to connect to the Internet (and a current connection doesn't already exist), the program uses the DUN entry described as "default" (when set properly) and dials out and connects.

Here is my problem... When the program finishes and the disconnect command is issued, the internet (modem) connection is left active.

If my program created the connection, I need to tell the modem to hangup, but I don't know how to do that OR even how to tell if my program caused the modem to create the dialup connection.

Added later:
HELP! I'm still struggling with getting the modem to drop the connection. Any ideas appreciated.
Found the answer and it is shown in posting
viewtopic.php?t=2813
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mandy.

Okay this may be a stupid question but I am completely lost. I am trying to make my own website through my internet provider. However, they told me to come here and register so I can obtain an FTP client code. Okay so now I am registered. What is my FTP client code? I am confused.
Mandy

[url]mailto:mandy84@bayou.com[/url]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.
Originally posted by mandy

Okay this may be a stupid question but I am completely lost. I am trying to make my own website through my internet provider. However, they told me to come here and register so I can obtain an FTP client code. Okay so now I am registered. What is my FTP client code? I am confused.
Mandy

[url]mailto:mandy84@bayou.com">mandy84@bayou.com
@Mandy: WHAT? If I understand you right, your provider told you to signup here for creating your website!?!? If you need an FTP Client use FlashFXP or CuteFTP. With this you can upload your created HTML Website to the Providers Webserver.

Mike

Tranquilizer/ Secretly!
<a href="http://www.secretly.de[/url]
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Henrik.

Oh no!
Hi Mandy.
So sorry if you can hear me smiling.
But u can get an okay Free Ftp-Client here:
Go for "WS-FTP LE 5.08" it's freeware and it's okay.
http://www.tucows.com/ftp95_default.html

Third from bottom is "WS-FTP LE 5.08"
Then choose(click) on your Os Win95/8,Me,2k,NT,Xp, what ever.

Then Choose your country, then you get a download link near you.

k.
regards
Henrik.
Post Reply