I used a slightly similar solution according to my need. Perhaps this may help someone here.
You need to start a new Socket port when starting the server or when loading the application. I used the @scheduler annotation, whereas you can also use a listener based solution.
@Scheduled(fixedDelay = 1000 * 60 * 60 * 24 * 365) public void startListenerPort() { ServerSocket socket = new ServerSocket(9999);
Just make sure that you allow TCP traffic on the port that you assigned to Socket (Firewall Settings).
Thus, you can have TCP traffic on port 9999, where your application server will continue to work on another port, as usual.
Badal source share