TCPSocket reconnect issue on Mac

I think it’s suppose to be like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
	<dict>
  		<key>NSAllowsLocalNetworking</key>
     		 <true/>
	</dict>
</plist>

ahh. thanks. Changed it but still the same issue.

Try runnign this command in Terminal:

while true
do
  lsof -nP -iTCP:XXXXX  # replace with the Port number you are using
  sleep 2
done

it may help you debug and see which socket(s) are getting stuck open?

I wonder if this is the problem. I’m pretty sure you ought to be using ServerSocket even if you only serve up a single connection.

FYI, ServerSockets use TCPSockets - see ServerSocket — Xojo documentation so you don’t need to change your code much.

Probably is only a problem to close connection at right time.
you have a Desktop App (D) with a Listner (L) and a Talker (T), and the same on MCU (M)
At start up the D have to start Listner (DL->listen) and wait message on the same port from MT and try to talk to the M server. DT->connect
At this point is M is ON all is ok.
Now you shut down the M.
DL raise an error 102 (connection lost) and must restart the Listner (DL->listen)
The same error is raised on DT (since there is not a Listner for its connection), you try to connect again (DT->connect) and receive a 22 error, so you will retry (timer) the connection works
The same is for the M but it should already do this since it’s a two channel communication (one to one)
Since it’s one to one you don’t need a server socket.
As already said, use close and don’t use disconnect and remember to out a flag in order to don’t restart the Listner when you are closing the app

These errors aren’t raised though. Or actually, they probably are, but it takes minutes for it to happen so for all practical purposes, it’s like they’re not. We can’t go that long.

For now, I’ve put the mac stuff on the back burner and am working in Windows, where it just works without any modification. Windows is the target platform for this system anyway. There is an outside chance we’ll want to try this setup out on a Mac, but we won’t make that call until we’ve done some extensive performance testing, and we’re months away from that.

Thanks!

That’s absolutely odd.
You should have them immediately
Now I can’t test against a real device, but some time ago I had a similar setup and these errors come up immediately

When I have some time I’ll look into it further. That said the bigger issue for us seems to be in the other direction, where the Xojo application is quit and restarted, vs restarting the MCU. While both have issues, on the mac, it’s impossible to quit the app and restart it, without having to run through the entire procedure in outlined in Scenario 1 above, to get it into a working state. We are using TCPSocket.close in the App.Close event, by the way, but it doesn’t seem to do the trick.