Announcement

Collapse
No announcement yet.

Active Passive Modes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Active Passive Modes

    I have been using Don's excellent FTP functions and they work well.

    I have come to an issue where an FTP server I need to work with does not support Passive mode only Active.

    Can Don's FTP functions be changed to support Active mode?

    If not has anyone else faced this issue?

    Suggestions?


    Thanks,

    John Schexnaydre

  • #2
    Anything is possible if you have the source. You can look up the FTP RFC (Files are available for download here too) and see the specs on how it works and rewrite the function. It is mostly a difference on who connects to who for the data channel, everything else should work the same. I wrote my own HTTP Web Server and an app to connect to a piece of hardware by FTP this very same way just by reading RFCs. It helps to have apps like WireShark and stuff too to watch packets and see what goes on. Some developers don't read very well and end up making a server that doesn't follow specs, so you have to figure out what they did wrong and allow for it, etc.

    Also, I think I looked at his or someone's functions for ideas too and there was a switch to change modes...
    Last edited by Roger Garstang; 1 Jul 2008, 05:47 PM.
    sigpic
    Mobile Solutions
    Sys Analyst and Development

    Comment


    • #3
      I recently posted some FTP access code which shows active and passive connections.

      Let me see if I can find it...here it is...
      WinInet FTP Upload (Overwrite or Append) Demo 3-10-08

      MCM
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Active Passive Modes

        Thanks!

        I had already started looking at Wininet. Seems like a good route to go.

        I still may take a look at how the FTP PORT command works and see if I can get that to work in Don's FTP functions. That would be the safe way to go as I would have less new code to write and test.

        Many thanks again!

        John

        Comment


        • #5
          In working with the WinInet Functions, the FTPPutFile function attemps
          Passive Mode which I cannot use.

          I see a Flag to Set Passive Mode, but none to set Active or fall over to Active if Passive mode fails.

          Anyone knows if/how FTPPutFile can be set to Active mode?

          Thanks

          John Schexnaydre

          Comment


          • #6
            Originally posted by John Schexnaydre View Post
            In working with the WinInet Functions, the FTPPutFile function attemps
            Passive Mode which I cannot use.

            I see a Flag to Set Passive Mode, but none to set Active or fall over to Active if Passive mode fails.

            Anyone knows if/how FTPPutFile can be set to Active mode?

            Thanks

            John Schexnaydre
            Not to be obvious, but try setting "SetPassiveMode" to %FALSE

            Comment


            • #7
              The above post was a bit glib. I apologize. The Help file states that

              &H80000000 ' Long-integer constant (signed)

              The Binary equviliant for that is "1" or TRUE. Try changing the variable to &H00000000 or FALSE.

              Again excuse my glibness, it was a long and arduous day.

              Comment


              • #8
                Thanks!

                Tried with only &H00000000 and call still atemps to use Passive.

                Comment


                • #9
                  I don't know if you're interested in using a commercial library or not, but if you don't want to thump your head against WinInet, our SocketTools Library Edition product supports both active and passive FTP transfers, and it's a heck of a lot easier to use (in my admittedly biased opinion). If you're interested, shoot me a PM and I can get you pointed in the right direction.
                  Mike Stefanik
                  sockettools.com

                  Comment


                  • #10
                    Thanks All.

                    I got a reprieve. The test server at the 3rd party doesn't support Passive.

                    Our customer received his server and it does support Passive.

                    So off the hook today, but I'm sure this will come up in the future so I plan
                    to continue looking to upgrade my FTP functions to support Active and Passive modes.

                    Some quick searches for WinInet FTPPutFile function shows that it does't support Active mode. But if so then why have a flag to set Passive mode?
                    Strange.

                    John Schexnaydre

                    Comment


                    • #11
                      Iteresting, indeed....

                      http://cboard.cprogramming.com/showthread.php?t=49993

                      Comment


                      • #12
                        Strange, my last reply disappeared!

                        Above I had already tried 0 with no success.

                        Thanks
                        John

                        Comment


                        • #13
                          Originally posted by John Schexnaydre View Post
                          Strange, my last reply disappeared!

                          Above I had already tried 0 with no success.

                          Thanks
                          John
                          I know you did that is why the response from the other forum was so strange. It failed for you but worked for him.... very strange.

                          Comment


                          • #14
                            And it appears the answer is:

                            %INTERNET_OPEN_TYPE_DIRECT=1

                            Comment


                            • #15
                              Originally posted by John Schexnaydre View Post
                              And it appears the answer is:

                              %INTERNET_OPEN_TYPE_DIRECT=1
                              Did that fix it? What were you using originally? The original code I posted had %INTERNET_OPEN_TYPE_DIRECT defined as &H1

                              Later:
                              Never mind I just got it. You're opening not as %INTERNET_OPEN_TYPE_PRECONFIG but as %INTERNET_OPEN_TYPE_DIRECT and setting the %INTERNET_FLAG_PASSIVE to 0 (Zero).
                              Last edited by John McWilliams; 8 Jul 2008, 06:41 AM.

                              Comment


                              • #16
                                Correct. It would seem you would need to try Active mode and if that fails reconnect and try again with Direct.

                                Here is the link to a major find in my searching:

                                http://www.codenewsgroups.net/group/...topic6364.aspx

                                Some good utility functions as well like the error code to text message, etc.

                                Also I wonder if something like this would work?

                                INTERNET_OPEN_TYPE_DIRECT OR INTERNET_FLAG_PASSIVE

                                Comment


                                • #17
                                  Also I wonder if something like this would work?

                                  INTERNET_OPEN_TYPE_DIRECT OR INTERNET_FLAG_PASSIVE

                                  Didn't work for me.

                                  Comment


                                  • #18
                                    I'm on vacation right now so I'm not exactly in "code mode" I will take a look at the link and see what's going on though. Thanks for sticking with the "problem".

                                    Comment

                                    Working...
                                    X