Announcement

Collapse
No announcement yet.

FTP file from host to client after first receiving file from client

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

  • FTP file from host to client after first receiving file from client

    Hello, I am trying to use network transfer and windows functionality I am unfamiliar with to accomplish the following:

    Abstract: I am trying to capture enough information from a client during an FTP file transfer from the client to my host server so that I can initiate an FTP file transfer back to the client at a later time. The client can operate in client/server mode if needed.
    Sorry for the long winded explanation but I've found it more useful to be verbose on the front end for clarity's sake.

    The hardware setup consists of my product that is installed in a customer's home and has a wireless network card in it (cool product called WiFly from roving networks http://www.rovingnetworks.com/documents/WiFlyGSX-um.pdf) and can successfully initiate a TCP/IP FTP session with my host computer (sitting in my office) at a fixed IP address to periodiocally (4x daily) push a file into my computer. This part of the process is working fine (file transfer from my product in customer's home to my computer in my office).

    The path the file takes is from: My wireless product in a customer's home -> wireless access point (Cisco wireless router I control, CAT5 wired to the home owner's router, gets it's IP via DHCP from home owner's router) -> home owners router (I may not have much control over this router's settings) -> home owner's cable modem -> internet -> my cable modem (with fixed IP address) -> my router ->my host computer running an FTP server (based on MarshallSoft's FTP Client Engine Library for PB).

    The first file transfer is initiated by my product to my computer after it is installed at the customer's home and that works fine. The product initiates the FTP session, my computer has an FTP server listening and waiting, the file is received and the session is closed. During that first transfer from the my product in the customer's home to my computer, I would like to be able to capture the necessary information needed to do a file transfer in reverse: initiating an FTP file transfer from my computer back to my product at a later time (event based).

    To summarize what I would like to do and the subsequent file transfer path:
    Capture necessary info during incoming FTP file transfers from my product (IP address from customer's home?) -> Initiate an FTP transfer from my computer to my product -> send file to my router -> my cable modem -> internet ->home owner's cable modem -> home owner's router -> my Cisco wireless router -> my product

    I can do an FTP Get command from my product to my computer but I also need to have the ability to initiate a transfer from my computer to my product based on specific events. I do realize that if the home owner's cable modem's IP address changes prior to my product's next file upload into my computer, I would not be able to communicate to that particular unit until I received it's next file transfer where I could then capture the new IP address and then push the file to the unit.

    As I see it, I face a number of problems that I know about and undoubtedly a larger number of problems I am unaware of:

    1) Is it possible to capture the home owner's cable modem IP address during the FTP session initiated from the product to my computer? if so, what PB code would help facilitate capturing that IP address and where within my FTP server code would I insert it? Part of the reason I want the home owner's IP address is that I realize it will change over time so I need to capture it and compare it to that product's previously sent IP and update if it has changed. I've seen some very daunting WinSock code in some of the source code examples and it's far beyond the type of programming I am familiar with Relevant post on ws2_32.dll

    2) What information is needed for my computer to initiate an FTP file transfer back to my product? Even if I have the IP address of the home owner's cable modem, is that enough to be able to initiate an FTP file transfer to my product from my computer given all the routers I have to go through? Is there additional information I need like the MAC address from my product's wi-fi card or the IP address of the wireless router in the customer's home as assigned by the home owner's router? What PB code would help to collect all the necessary information so I could FTP back to my product?

    3) How reliable would this process be if it could be accomplished (excluding what I already know about the problem of the home owner's cable modem IP potentially changing over time). Will software fire walls in the home owner's computer prevent the transfer back to the product? What would I have to tell the home owner to do or not do to his router to make this happen (hopefully not much)? If the IP address of my router changes (as issued by the home owner's router running DHCP) will that cause problems? etc.

    4) What would I have to require from the home owner to do to his router to allow the file to be uploaded to my product (ex. packet forwarding)? My goal is for the home owner to not have to do anything to their router outside the normal default settings of the router since I can't rely on the settings remaining the same in case they change out their router or reset it.

    5) Less important at this time but will be important in the future: what steps should I take to make the FTP transfer from my computer to the product more secure (I'm less concerned with the transfer from the product to my computer). I have less capabilities at my product's side of things since it's not a computer running an OS. Things like

    If there is a PB library that would help facilitate this ie. allow me to write easier code at a higher level (rather than getting down to the WinSock level) I would be happy to purchase it (something similar to Marshallsoft's TCP/IP Library, although there's no PowerBuilder version). As far as I can tell there's nothing the the Marshallsoft's FTP Client software that I already own to accomplish any of this (I could be wrong).
    I found functions like gethostbyaddr() in the WS2_32.inc in some of the sample code posted but I'm not sure if that's what I need or how to implement appropriately.
    Easy to understand code samples would be much appreciated. If you have some insight on a particular question, please reference which number (1-5) you're answering for ease of discussion.

    Thanks very much for your help! The PB forums is one of the main reasons I went with this product.

    -Robbie Clark
    Last edited by Robbie Clark; 31 Aug 2009, 02:39 PM.

  • #2
    Originally posted by Robbie Clark View Post
    Abstract: I am trying to capture enough information from a client during an FTP file transfer from the client to my host computer so that I can initiate an FTP file transfer back to the client at a later time.
    The short answer is that you can't do this with a client/server setup. FTP servers wait for requests from FTP clients. They cannot "push" data to clients nor force a client to initiate a request.

    What you're describing is peer-to-peer networking, where both processes can act as both a client and a server.

    I'm not saying that you will not be able to accomplish your data transfer goals, just that you will not be able to get a generic FTP server to initiate any type of data transfer with a generic FTP client.

    [edit] I thought I would add the following: The simplest approach would be to build some type of polling mechanism into your client-side product. At some regular interval it would poll a process on your server and, if necessary, initiate the FTP request from the client side. This also avoids some of the floating IP, and security issues.

    --
    Kevin Powick
    Last edited by Kevin Powick; 31 Aug 2009, 12:51 PM. Reason: added thought, fixed spelling and grammar
    --
    Kevin Powick

    Comment


    • #3
      May be useful, maybe not....

      WinInet FTP Upload (Overwrite or Append) Demo 3-10-08

      MCM
      Last edited by Michael Mattias; 31 Aug 2009, 07:21 PM. Reason: Corrected Link
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        update: wireless module has both client and server ability

        Thanks Kevin,
        Something I left out in the description of the Roving Network wireless module inside my product in the customer's home: it has the ability to act as both an FTP client and server if that would help to initiate the push process from my host FTP server. I would still need to capture the necessary information from the product's initial FTP transfer to my host computer in my home.
        Thanks,
        -Robbie

        Comment


        • #5
          Originally posted by Robbie Clark View Post
          Thanks Kevin,
          Something I left out in the description of the Roving Network wireless module inside my product in the customer's home: it has the ability to act as both an FTP client and server if that would help to initiate the push process from my host FTP server. I would still need to capture the necessary information from the product's initial FTP transfer to my host computer in my home.
          -Robbie
          But the issue is that you want the server at your office to initiate some type of push/transfer. In that case, the office server would need to act as a client to initiate communication with the customer side now acting as a server.

          I still think you're looking at a somewhat complex solution with such an approach. It would be much, much easier to have the client poll your server at regular intervals. The implementation should be very easy and the network overhead is very low. No more than an e-mail client doing a POP3 mailbox check. You can even think of it that way. Client ask server, "Is there anything for me?" If yes, then client initiates the FTP transfer.

          Again, it avoids problems with IPs that might change and alleviates some security concerns on the client side.

          --
          Kevin Powick
          --
          Kevin Powick

          Comment


          • #6
            Originally posted by Michael Mattias View Post
            Link doesn't work for me.

            --
            Kevin Powick
            --
            Kevin Powick

            Comment


            • #7
              Agreed... however

              I agree Kevin. Thanks again for your suggestion, it would be much easier to have the client poll the server at specified time intervals to see if a file needs to be retrieved. However, my requirements stipulate that I need the ability to initiate the transfer from my computer to the product based on an event in case I can't wait for the next scheduled poll to take place. We are looking at an installation of over 10,000 units installed in client's homes and can't have them all pinging the server several times per minute to see if a new file exists to get.
              Thanks again Robbie

              This link should work to that file posted above
              http://www.powerbasic.com/support/pb...611#post278611

              Comment


              • #8
                Hi Robbie,

                Thanks for the additional information with regard to the scale of your deployment. I guess you'll have to look at some type of P2P approach.

                --
                Kevin Powick
                --
                Kevin Powick

                Comment


                • #9
                  Link fixed.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Does this have to be FTP?
                    Client could execute a "TCP CLIENT/HOST" program at boot-up.
                    You would receive the IP, port, client number and anything else you need.
                    If files are available, they could TCP RECV them immediately or check at intervals.
                    This enables sending or receiving on either end.

                    Comment


                    • #11
                      Great idea!

                      Great suggestion Mike. I think that would actually do the trick. After I reread the documentation on the Wi-Fi module, the transfer does not have to be FTP. I will look into how to pull the IP out of the incoming TCP Client stream. If you know of any code that would help facilitate grabbing the incoming IP that would be great. I'll dig around the code depot.
                      Thanks again!
                      -Robbie

                      Comment


                      • #12
                        Forget about using FTP and and just do your own simple information transfer package. If at the start the client computer first sends a UDP packet to your static IP server then the IP address that is available in the standard UDP RECV statement will be the external IP address of the clients router/modem.
                        From that point as you know the IP addresses of both ends you can establish any sort of TCP/IP conversation you wish.

                        Comment


                        • #13
                          I have been working with a TCP server and transmiting a 100,000,000 byte file in about 17 seconds. 10 megabytes in about 1.2 seconds.
                          This is up and down the internet within my own network.
                          If anyone is interested in seeing what type of performance is obtained between our networks (cable or dsl) please let me know and I'll put
                          together a test. This makes FTP look like a snail.

                          Comment


                          • #14
                            If you know of any code that would help facilitate grabbing the incoming IP that would be great. I'll dig around the code depot.
                            Robbie,
                            Better late than never.
                            Code:
                            FUNCTION TCPADDR(BYVAL lSock AS LONG) AS STRING
                              'Paul Purvis code to get remote IP and port from client
                            
                              LOCAL sa AS sockaddr_in
                              LOCAL l AS LONG
                              LOCAL lHandle AS LONG
                              LOCAL b AS BYTE PTR
                              LOCAL lSockHandle AS LONG
                              lSockHandle = FILEATTR(lSock,2)
                              l = SIZEOF(sa)
                              IF getpeername(lSockHandle, BYVAL VARPTR(sa), l) = 0 THEN
                                b = VARPTR(sa.sin_addr.s_addr) 'return IP address of connection
                                FUNCTION = USING$("#_.#_.#_.#", @b, @b[1], @b[2], @b[3]) + " on remote port" + STR$(sa.sin_port)
                              END IF
                            END FUNCTION

                            Comment


                            • #15
                              Hello Robbie

                              I am trying to use wifly product to send and receive files from my product (8051 procesor) to a FTP server, such as windows 2003 server. My product initiates the FTP session, user, password... I can make directory, delete files, create an empty file, but i dont know how to transfert data in the files, is it posible to acces to the data conection (generaly port 20)?
                              I have the same problem with the LIST command, i obtain:
                              150 Opening ASCII mode data connection for file list
                              226 Transfert complete.

                              but where are the datas???
                              Thanks for your help
                              best regards

                              Comment


                              • #16
                                This shows the public IP address the client needs to report to the server.
                                http://www.powerbasic.com/support/pb...d.php?p=351188

                                Comment

                                Working...
                                X