I have a C++ ROS node using ROSBridge to send the ROS Topics as JSON strings via TCP WebSocket over port 9090. On the same computer, I have a C# Unity program that needs to access the JSON and send some of its own. If I put this program on a different computer there is no problem--I can access port 9090 and see the JSON. But if it is on the same computer as the ROSBridge Host, then there is a conflict with using the same port. So the two applications cannot communicate with each other on the same PC but they can on separate PCs.
So what can I do? Must the ports match and thus always conflict or maybe I can somehow make Process A send on 9090 but receive on 9091 and Process B just the opposite or something? Any other options? In essence, I'm trying to get Unity to participate in the ROS communications, but it does not have native support for that and thus the workaround with the ROSBridge JSON strings.
It sounds like my understanding about ports was lacking. The host for the ROSBridge is being set up to use port 9090 so that anyone wishing to connect to it will request the host's port 9090 for the connection but will still use whatever port it desires on its own side. In both applications, I can state that the "Host" port is 9090 without conflict because the client application will still open a random other port for its own use to connect to the host port. Therefore, the trouble I am experiencing is something other than "port sharing" since that is not what is happening. Only one is hosting on 9090.