Thanks a lot.
James
"Richard Pilkington" <richardp@[EMAIL PROTECTED]
> wrote in message
news:QaqdnT2aC7dOE4TVnZ2dnUVZ8sOonZ2d@[EMAIL PROTECTED]
> James
>
> I use the Function below to check if a data server is visible using an
IP
> address. If you know the ip address of the host where the share is,
> perhaps it could help you.
>
> The function is called like this:
> if CheckLink("172.19.13.68",3306,500,2,"")
> // Continue
> else
> // show error
> endif
>
> Richard
>
> FUNCTION CheckLink(cServer AS STRING, n****t AS INT, nTimeOut AS INT,;
> nRetries AS INT, cLogFile AS STRING) AS LOGIC PASCAL
> // cServer = IP Address - String
> // n****t = TCP/IP ****t number (3306 for MySQL) - INT
> // nTimeout = Timeout in milliseconds - INT
> // nRetries = Number of retries before failure - INT
> // cLogFile = Full path to logfile to log success or failure,
> // null_string for no logging - String
> LOCAL oSocket AS cSocket
> LOCAL lReturn AS LOGIC
> LOCAL nAttempts AS INT
> LOCAL ptrHandle AS PTR
> LOCAL cLine AS STRING
>
> nAttempts := 0
> lReturn := FALSE
>
> oSocket := CSocket{SOCK_STREAM}
> oSocket:TimeOut := nTimeOut
> DO WHILE ((nAttempts < nRetries) .and. !lReturn)
> lReturn := oSocket:connect(cServer,n****t)
> nAttempts ++
> END
> oSocket:Disconnect()
>
> IF SLen(cLogFile) > 0
> IF File(cLogFile)
> ptrHandle := FOpen2(cLogFile, FO_READWRITE + FO_SHARED)
> ELSE
> ptrHandle := FCreate2(cLogFile,FC_NORMAL)
> ENDIF
> IF ptrHandle == F_ERROR
> ErrorBox{,"Unable to open connection log file!" + CRLF +;
> DosErrString( FError() )}:Show()
> ELSE
> IF !lReturn
> cLine := "Unable to confirm Network connection with server
"+;
> cServer+"("+NTrim(n****t)+") on: ";
> +DToC(Today())+ " at: "+Time()
> ELSE
> cLine := "Network connection to server "+cServer+;
> "("+NTrim(n****t)+") confirmed on: "+DToC(Today())+;
> " at: "+Time()
> ENDIF
> FSeek(ptrHandle, 0, FS_END)
> IF FPutS3( ptrHandle, cLine, SLen(cLine) ) == SLen(cLine) + 2
> ELSE
> ErrorBox{,"Unable to write to network connection log
file!"+;
> CRLF + DosErrString( FError() )}:Show()
> ENDIF
> FClose(ptrHandle)
> ENDIF
> ENDIF
> RETURN lReturn
>
> James Martin wrote:
>> This is happening inside a program. Can you "Net view" or "Ping" inside
a
>> program and get results that can be used for decisions?
>>
>> James
>>
>> "dlzc" <dlzc1@[EMAIL PROTECTED]
> wrote in message
>>
news:7f972435-801f-4829-8aaf-c01e5fb07068@[EMAIL PROTECTED]
>> Dear James Martin:
>>
>> On Apr 29, 9:14 am, "James Martin" <ja...@[EMAIL PROTECTED]
> wrote:
>>> I'm connecting to directories over a VPN, and
>>> sometimes the machines are not available at the
>>> other end. Instead of immediately going on there
>>> is a long wait before it returns with an error.
>>> File() does not help. Is there a way to determine
>>> whether a share (and of course a shared file) is
>>> available immediately?
>>
>> You can find the computer's name from "NET VIEW" if necessary.
>> You can parse the output of "PING <cName> -n 1 -w 10", to see if it
>> contains "Request timed out."
>>
>> If you get a hit, then you can see if drives are mapped, etc.
>>
>> David A. Smith


|