I have a setup where I’m sending data from SuperCollider to Processing (and vice versa) using OSC messages. The code looks like this:
osc = new OscP5(this, 12000);
address = new NetAddress("127.0.0.1",57120);
OscMessage events = new OscMessage("/events");
osc.send(events, address);
The listening port is set to 12000 in this example and using the same number in SC, the transmission works fine. However, after executing and stopping the program, the next time I run it I get the following error:
ERROR @ UdpServer.start() IOException, couldnt create new DatagramSocket @ port 12000 java.net.BindException: Address already in use: bind
I guess I kind of get it, but I also don’t. I mean, it’s still the same two programs and the same sketch. The workaround is to change the port after every run in both programs but that is annoying. I suppose I could run a loop to find a free port and then send the port to SuperCollider so that it can send something back, but that seems not ideal. Is there a way to reuse the same port over and over again?