Hi Wayne.
Thanks to your example and more testing I’m making some progress but things may still not be working correctly.
Additional errors I was receiving was a 105 AddressInUseError. Strangely this 105 error would happen every other time when being run from either the IDE or a build. The alternate run would be ok and not throw me the 105.
When that error occurred the listening IPCsocket would not work so a connection would not be made resulting in a failure.
The documentation does not clearly say why this error happens or how to correct it but I figured out it’s because I wasn’t deleting the created socketfile before trying to run or rerun the listening process. The documentation also doesn’t say why sometimes the IPCsocket listening process will work but then when rerun it fails throwing the 105 error but I figured this out too.
The lack of consistently throwing errors complicated this situation as did the documentation’s suggestion of hiding the socketfile from visible view. It turns out the IDE and build are secretly deleting the existing socketfile if one exists after it throws the 105 failure. More specifically it’s probably when the IPCsocket calls .listen on a pre-existing socketfile should one exist. That means if you first run a good IPCsocket example that calls .listen it won’t throw you a 105 and your project should accept a connection. But, the next time you run the same example and now the socketfile exists you get tossed the 105 and your process will not accept a connection. However the sneaky IDE and build doesn’t tell you it secretly deleted the offending socketfile which means the developer has no idea why it’s failing.
Doing this over and over while checking and changing your code trying to figure out what’s going on is about as much fun as smashing your head into a brick wall.
The documentation section pertaining to this matter for IPCsocket currently says :
“The file might remain in existance even after closing the connection, so you should delete any leftover files from previous connections when you make a new connection.”
It doesn’t mention anything about causing errors, not working correctly, or alternately working then throwing errors every other run.
The wording wrongly indicates that you might want to clean up the left over files if you don’t want them hanging around.
The documentation should be amended to state something like I’ve written below :
ERRORS :
105 AddressInUseError :
If you receive a 105 AddressInUseError while using an IPCsocket (please run to the nearest wall and smash your head into it twenty times) it is because there is an existing socketfile of the same name which has not been deleted before your IPCsocket listening process is trying to call .listen. When receiving the 105 error your listening IPCsocket process will not work and no connection to it can be made. To prevent this error you must first delete an existing socketfile of the same name in the same location before your IPC listening socket process tries to create and call .listen on it. You may do this by having your IPCsocket listening process delete the socketfile after it’s finished it’s job and before it quits. Alternatively, when your IPCsocket listening process is first run you may want to check if there is an existing socketfile of the same name in the same location and if one exists delete it before your process creates the socketfile and calls .listen.
Please note you only want to delete a pre-existing socketfile for a process that intends to receive a connection by calling .listen. You do not want to check for and delete an existing socketfile before making a connection using an IPCsocket in a client that is calling .connect because this may delete the correctly created and necessary socketfile created by the listening IPCsocket which is required for successful communication.
Yes this was a PITA to deal with and I wasted hours figuring it out.
Oh sorry that last part probably shouldn’t go in the documentation
That’s the wordy version for people who like more details. A truncated version could alternatively be used :
ERRORS :
105 AddressInUseError :
Target: Mac OS X
Build : Console
Cause : Pre-existing identically named and identically located socketfile conflicting IPCsocket .listen call.
Solution : Delete any pre-existing identically named and identically located socketfiles before trying to call .listen on them.
Confirmed : OS X 10.6
Wayne, we’re not done yet!
More IPCsocket strangeness :
After making the needed path modifications and 105 solutions to your example, it now seems to be connecting and sending the timestamp back correctly (thank you ) but I’m getting a strange
msg upon connection.
I don’t see anything in the documentation that says IPCsocket is supposed to output and it doesn’t make sense that it should especially on a successful connection.
Anyone know why IPCsocket is outputting a message upon connection?
I’m wondering if IPCsockets are reliable enough to use on Mac?
We customers should be able to append to the online documentation.
It would save other developers valuable time, stress and improve this product.
Why can’t customers append the Xojo documentation with notes, code and example projects?