IPCSocket Troubles in Windows - What do the errors mean?

Hey all,

I am having a bit of trouble with setting up an IPCSocket in Windows. Here’s my path:

MyIPCSocket.Path = SpecialFolder.Temporary.Child("com.jas.mediaswitchersocket").NativePath

I have two apps that I use to communicate but I don’t know which app starts first. So my socket is written so that the app can be either a listener or a connector.
Now, when I first attempt to use the socket I am getting an error code of 103 which is a name resolution error. So I think you get that when you try to connect to the socket but there is no listener. So then in the error method, I set the socket to listen mode.

Now I start my second app and I get the error code 103 again. I don’t think that should happen. Then I get an error code 105 (AddressInUse error) when I try to listen which would make sense…

It appears something is preventing my IPC file from being created. Windows has always been a little wonky for me with IPC. It used to work but I made some changes to my code and now it doesn’t. The exact same code runs perfectly in OS X. So I feel the basic methodology I am using is correct, but I am doing something wrong that is specific to Windows…


You may want to use shellpath instead. If there are spaces in the path, that may choke the IPC.

I’ll try that and I thought you might have been on to something there, however, there are no spaces in the path right now (there could be though as TMP is in the directory based on the user’s name). I’ll try it.

I’m curious… Why is the path needed for this class?
Is this a fifo file?

IPCSockets use a file to communicate.


Sounds slower than using and TCP Socket to localhost doesn’t it?

Well it’s what Xojo recommends to use for inter program communications. The problem with TCPSockets is that you can’t have two apps that have grabbed the same port. So it won’t work.

Here’s what I do https://forum.xojo.com/21239-how-to-keep-multiple-ipcsocket-connection/p1#p177775

But that’s not my problem. I can’t get ONE socket to work!

Windows may not like that ther are 2 dots in your filename. Perhaps you can ty a path like “jas.mediaswitchersocket” instead?

Als is the file and path readable/writable?

John will a serversocket with NetworkInterface.Loopback work for you? That is the same machine only, not sure if it works with serversocket…

@Jon Ogden - why not test with just “c:\temp” as the path for IPCsocket.

I just played with the IPCSocket example. I created a path with a space into it, but it works just fine with nativepath.

So the issue you report must be due to something else.

Could you try to run the example ? Just build one to run it, and run the second in the iDE. If you get the same error, I suspect it may have to do with an antivirus blocking the TCP port used by IPCSocket.

I just use TCP sockets as that is what is used on Windows anyway. See https://forum.xojo.com/20033-ipcsocket-protocol-info/p1#p168010.

Well, I figured out my problem. And I’m not sure if it was Windows only or not.

My IPCSocket is part of a singleton class that handles both IPC and UDP communications. I had only recently made it into a singleton. When I first attempt to write to the socket I have a public method that creates the object, sets it up and starts the connection attempt. However, then in the write method, I was checking to see if the socket is connected and if not, then I call connect again. It was making this second connect call that mucks things up. From the first call to connect to the second, there was not enough time for the framework to make the connection and respond back that it was connected. Now that I am handling things correctly and not calling connect twice, it works just fine.

Interesting. So that’s why I can never find the file…

Possibly related? <https://xojo.com/issue/10925>

It’s possibly connected. However, I have my own Boolean variable for my parent class that gets set to true when the IPCSocket.Connected event fires. There is a finite amount of time between calling connect and getting the connection. Any time you call Connect with an IPCSocket and then call connect again (even after it’s connected), it messes things up and throws error number 103 (Name Resolution Error). Xojo should make it more robust so that if you call connect after the socket is connected, it just ignores it.

The path on Windows is just bogus, due there is no native IPC socket in Windows.
Xojo simply translate the path to a port number, due on Windows a loopback TCP connection is used.

Hence you can use whatever you want as path.

[quote=387242:@Massimo Valle]The path on Windows is just bogus, due there is no native IPC socket in Windows.
Xojo simply translate the path to a port number, due on Windows a loopback TCP connection is used.

Hence you can use whatever you want as path.[/quote]

So I’ve learned. But that was not my problem. The problem was calling the connect method on an IPCSocket that was already connected. I corrected that and things work great now.