IPCSocket.Path
From Xojo Documentation
or
StringValue = aIPCSocket.Path
Supported for all project types and targets.
Path to a directory that you have write access to, followed by the name chosen for your socket (maximum of 103 characters).
Notes
Use FolderItem.NativePath to assign the proper path type for all platforms. On Windows, this is an absolute path, e.g. "C:\Temp\mySocketName", while on Linux and macOS it is a POSIX (Unix) path, e.g. "/var/tmp/mySocketName".
The name and path can be chosen arbitrarily. Ideally, the path should be a private folder you have full control over or, preferably, the system’s temporary items folder.
If you choose a folder you share with other applications, such as the temp folder, you need to ensure that the socket file name is unique to avoid conflicts with other applications that might want to place files into the temp folder as well. Therefore, use a name specific to both you and your application. On macOS, the application bundle identifier, made up from a domain name owned by you, is a good technique.
If you use SpecialFolder.Temporary to create the IPCSocket file, then the name of the file cannot be the same name as a Mutex (as it also uses that folder). |
Also, if one app invokes the other, the first app could create a random file name and pass its path to the other app. Keep in mind that you may end up with lots of socket files in that folder this way, unless you make sure to delete them after you stop using the IPC socket, as the files don’t get deleted automatically (however, macOS and Linux clear up the temp folder upon system restart, so that's one reason why using that folder is recommended).
Examples
Here's an example for a fairly safe generation of the socket path:
// and replace myAppName with you app's Name:
Var chosenName As String = "myEmail.emailDomain.xyz.myAppName.socket"
Var chosenFolder As FolderItem = SpecialFolder.Temporary
IPCSocket1.Path = chosenFolder.Child(myAppName).NativePath