Accessing a network folder on another domain

I’m using the following to access folders on our domains.

This seems to work fine when the drive is available (the machine is powered on), but there is a long timeout period where the app locks up while trying to connect to machines that are not powered on.

Any suggestions for a better way to handle this?

Thanks.

[code]If lbContents.SelCount > 0 then

Dim currentComputer as FolderItem

currentComputer = GetFolderItem("\\\" + lbContents.Cell(Current_Row_lbContents, 1) + "\\C$")

If currentComputer <> nil then
  currentComputer.Launch
Else
  Call MsgBox("Could not connect to " + "\\\" + lbContents.Cell(Current_Row_lbContents, 1) + "\\C$" + ".", 16, "Connection Error")
End If

End If[/code]

This is caused by the underlying network activities.
To avoid this problem in Xojo you must create another OS system thread because Xojo threading system it’s based on cooperative scheduling and doing this in a Xojo thread does not solve the problem.

The suggested Xojo way to do it it’s to use an helper app that execute the request and post the result to your main application.
The helper app can be a console application using an IPCSocket to communicate with the main app.

If all it’s required it’s what is contained in your example you can avoid the communication between the two apps and simply execute the code in the helper app passing the folder item name to it as a command line parameter.

Regards.

That sounds like a valid option.

I think I am going to try to somehow determine if the machine is online first and then just not attempt to connect if it isn’t available.

Pinging seems to work to check whether or not the computer is up.

When the other machine is not up, there is a pause of about 3 seconds in which the application freezes. This is more acceptable than 30+ seconds when trying to connect to the drive of a machine that isn’t accessible.

When not accessible, shell returns, “Shell timed out”

Is this too simple? Always suspicious of things that appear to be too simple…

[code]Dim sh As New Shell
sh.Mode = 0

sh.Execute(“ping theServer -n 1”)

If InStr(0, sh.Result, “Pinging”) > 0 Then
MsgBox “Host is up.”
Else
MsgBox sh.Result
End If[/code]

Some system are configured to not reply to ping requests.
Another things to take in account it’s the availability of the shared directory.

So this can be done in a very simple way or, in some cases, can become very convoluted.

Instead of ping, as the network share uses an SMB port ( 445 ) then you can try to open a TCP socket on that port and then wait for a timeout period of your own to see if it is there…

The code at http://documentation.xojo.com/index.php/TCPSocket is a good base.