×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Com Server Process

Com Server Process

Com Server Process

(OP)
I am trying to confirm a FTP connection -
When the connection is OK, I get a quick response, all is good.
When the connection is no good or the wrong host is provided it takes a long time for the connection to return failed.
This causes a hang.
So I made a out-of-process com exe to run the task, but I am still having similar issues.
I could wait the amount of time, yes and then continue. This will work, but the wait time is somewhat excessive.

Once the reference to the com exe is created, it still needs to wait while it runs its task, before it can be released.
Is there any other solution to checking for a remote FTP connection? Something like 'If you don't respond in 'x' amount of seconds, then the connection failed'

I am using WinInet at the moment.

Alastair

RE: Com Server Process

Hi Alastair,

Checking if an IP connection is valid can also be done via iphlpapi like this:

CODE --> FoxPro

FUNCTION isAlive
LPARAMETERS vIpNum, vSilent

    * declaration 
    DECLARE INTEGER GetRTTAndHopCount IN Iphlpapi;
       INTEGER DestIpAddress, LONG @HopCount,;
       INTEGER MaxHops, LONG @RTT
    DECLARE INTEGER inet_addr IN ws2_32 STRING cp

    * variables
    LOCAL lnDst, lnHop, lnRTT, llReturn

    lnDst        = inet_addr(m.vIpnum)
    llReturn    = .F.
    STORE 0 TO lnHop, lnRTT

    * ping IP and if return=0 ping was negative
    IF GetRTTAndHopCount(lnDst, @lnHop, 5, @lnRTT) = 0

        TEXT TO lcMsg TEXTMERGE NOSHOW PRETEXT 3
            IP-adress <<m.vIpnum>> doesn't respond
        ENDTEXT
    
    * otherwise IP is accessible
    ELSE

        TEXT TO lcMsg TEXTMERGE NOSHOW PRETEXT 3
            IP-adress <<m.vIpnum>> response
            (<<m.lnRTT>> MSek / <<m.lnHop>> Hops)
        ENDTEXT
        llReturn = .T.
      
    ENDIF

    * if message is allowed, then show response infos
    IF NOT vSilent
        MESSAGEBOX(lcMsg,0+64+0,[IP reponse time])
    ENDIF

    * returnvalue .T. = successful, .F. = no response
    RETURN llReturn

ENDFUNC 

Can't remember how long a negative response will last, though. I used that code in ~2007/2008 and remembered, that I had placed it in my blog sometime.

HTH

-Tom
https://www.blogger.com/profile/089031659767875220...

RE: Com Server Process

I guess that'll help.

The idea an out of process COM Server will run in parallel also isn't wrong, but the nature of calls to its methods still is only returning after the method executed. The simplest method to create a separate EXE that runs in parallel does something and quit is to create a normal EXE and call it with RUN /N.

Otherwise, your method - say ftp_connect - should return before it connects, which is possible if you create a timer that does the real code in its Timer event, that is set to a small interval and that is releasing itself at the end of its Timer, the ftp_connect method then creates this timer, enables it and returns. Not long ago I also established an EXE COM Server to separate something from the main application this way, too.

In case Of FTPing the shoot off process might be enough, when you include a full batch of commands to do, that principle also is used in Craig Boyds VFPConnection.FLL: https://www.sweetpotatosoftware.com/blog/index.php...

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close