agraham147 wrote: ↑
Tue May 01, 2018 8:01 pm
...IP address change if you are using your software somewhere else so how can code it to find the IP address you are currently in?
Or to discover local services, Bonjour or other discovery protocol.
Most discovery protocols are UDP-based, and for whatever reason I've never wrapped my head around UDP well enough to write a good discovery mechanism, though I have with TCP by testing ports across an IP range. Sure, not recommended, but it works so who am I to complain.
I keep threatening to finish that up so it could become useful to others, but two things stop me:
1. UDP is the better method for local discovery, so on the rare day when I have a moment to think about that problem I find myself thinking about UDP instead of TCP.
2. I rarely have any interest in the problem at all any more at all, because P2P is only really useful on local nets, and most of what I'm working on needs to work both locally and on the Internet, where client-server is much more reliable and easier to build for.
In your case, if you're certain your system will never need to work across the Internet, local network discovery via UDP is widely considered your best bet.
But if there's any chance at all you may need to cross over to the Internet, client-server makes everything so much simpler, robust, predictable, monitorable, manageable, scalable, and every other adjective I can think of that I can't recommend it enough.