• Quick wininet api question (VB6 SP5)

    Author
    Topic
    #401420

    When using the wininet API, if a connection is made twice without closing it in between, will there be 2 connections or will it just re-establish a single connection?

    The line that calls the API is as follows (from MDSN):
    hConnection = InternetConnect(hOpen, txtServer.Text, INTERNET_INVALID_PORT_NUMBER, _
    txtUser, txtPassword, INTERNET_SERVICE_FTP, nFlag, 0)

    Any help would be much appreciated.

    Viewing 1 reply thread
    Author
    Replies
    • #790985

      I’ve never tried this, but I would expect a new connection every time you call that method. Otherwise, how would you create a new connection? Perhaps you can test this theory: If you debug.print the hConnection value, does it change after the second call?

      • #791192

        It does change, but does that necessarily mean the previous connection will be closed?

        When I have programmed myself a put or get module (or anything that actually uses the connection) I will make a connection and store the connection handle elsewhere, then make a new connection and see if the original one still works using a put or get command.

        While im on the subject of those commands. While writing my get command I noticed the file I specified disappeared from its original location. Does the “put” command move files instead of copy? I haven’t tested my theory yet but it appears that the get command moved my file, and where I boke and stopped the code, didn’t get to the writing stage, therefore my file disappeared completely!!!

        ADDITONAL: Just spoken to our ftp administrator and it seems there may be a program running to delete foreign files on the server, therefore that would explain why my files disappear, so unless I can get him to switch it off, testing is limited to small windows of opportunity – joy!

        • #791668

          > does that necessarily mean the previous connection will be closed?

          No, you might have any number of connection open. And that could be a bad thing…

          • #792266

            In other words, if im writing an FTP program, ill need to keep a log (in a variable or something) of any connections that are made and make sure they are closed if the program crashes or ends.

            I don’t suppose there is a way of detecting any open connections?

            • #793361

              I hope someone else can contribute, as I have no experience with this API.

            • #793362

              I hope someone else can contribute, as I have no experience with this API.

          • #792267

            In other words, if im writing an FTP program, ill need to keep a log (in a variable or something) of any connections that are made and make sure they are closed if the program crashes or ends.

            I don’t suppose there is a way of detecting any open connections?

        • #791669

          > does that necessarily mean the previous connection will be closed?

          No, you might have any number of connection open. And that could be a bad thing…

      • #791193

        It does change, but does that necessarily mean the previous connection will be closed?

        When I have programmed myself a put or get module (or anything that actually uses the connection) I will make a connection and store the connection handle elsewhere, then make a new connection and see if the original one still works using a put or get command.

        While im on the subject of those commands. While writing my get command I noticed the file I specified disappeared from its original location. Does the “put” command move files instead of copy? I haven’t tested my theory yet but it appears that the get command moved my file, and where I boke and stopped the code, didn’t get to the writing stage, therefore my file disappeared completely!!!

        ADDITONAL: Just spoken to our ftp administrator and it seems there may be a program running to delete foreign files on the server, therefore that would explain why my files disappear, so unless I can get him to switch it off, testing is limited to small windows of opportunity – joy!

    • #790986

      I’ve never tried this, but I would expect a new connection every time you call that method. Otherwise, how would you create a new connection? Perhaps you can test this theory: If you debug.print the hConnection value, does it change after the second call?

    Viewing 1 reply thread
    Reply To: Quick wininet api question (VB6 SP5)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: