I’m working on a data logger console app that takes both serial (rs-485) and ethernet (using an ethernet to rs-485 adapter) inputs. If I use just one input, everything works fine and multiple readings are recorded. If both serial and ethernet inputs are used, the serial reads first followed by the ethernet. For the second reading, the serial is fine, then the program hangs in the TCPSocket. Prior to each reading, I configure all the communication parameters. Part of that process is setting any previous parameters to nil. The ethernet to rs-485 adapter I am using is set to port 2006 which I set in the configuration routine. When I stop the debugger prior to the first write, the debugger show the port has been reassigned to something like 51696. When it is time for the second reading, the port is 2006 and the program hangs. The stop button in the IDE won’t stop it, but closing the console app window does. I am hoping someone can explain what is going on with these port numbers and how I can get control of them.
Earlier, I was not setting closing the socket and setting it to nil. The port number was still a random number in the 50000 range and the program still hung. Norman set me straight earlier that this was not related to the ServerSocket that is also in the app. Removing the ServerSocket and everything related to it did not solve the problem.