paulwratt wrote:good suggestion @pi-anazazi but I think this is not the issue, however it maybe worth checking anyway.
you are right @Solannis I dont know why you would need to ssh to Mac, when you are not using ssl connections, but it simplifies things if you are.
The reason I mention "step-by-step" is that one of those steps will pull an OS config option that has not been set, or set the same on the Pi's.
My final suggestion is to do a generic search, not Pi or Raspbian specific, as I can well imagine there has been exactly this sort of issue, especially with Java (and possibly Python) on various OS's, they will probably help.
I am sorry to not be more helpful with specifics, but please post results, especially when "sovled" (and change post heading too), as this will probably help me in the future too
EDIT: one last thought, in your code can you connect via IP address instead of server name, this may prove useful in finding an answer.
When you say step-by-step, can you be more specific? Are you referring to specific lines of code, or steps in the establishing of a socketed connection? Either way, since the Pi's can connect to the Mac, I know the code is right, so it is some specific configuration issue on the Pi's themselves that is the culprit, and that is what I am looking for help in ideas as to what to look at and where to look.
I have done many general Google searches, but most of them point at specific products/platforms (like NGinx and ssd and whatnot) and since I am writing this code myself (and, again, since it does work locally and from Pi to Mac), none of those posts that discuss those software platforms' settings really applies. I have yet to find something that says "Go to /etc/network and look at X and see if option Y or Z are set to n" or something that would be more OS-specific.
As far as connecting via IP address versus hostname, I have tried that and the results are no different in any test case. This is clearly a configuration issue on the Pi somewhere. I am not beyond wiping out the SD cards and trying another setup/reload. There is nothing I have done to configure them (other than the default setup) and no custom software on them (other than the code I have written), so I may just wipe them both out and try again and see if that makes a difference.
I am not usually the first person to try anything or have any problem, so I am somewhat surprised that no one else seems to have experienced this problem before. I will keep looking. I am just baffled that this hasn't already been experienced and resolved.