@Override public void run() { try { oftp = OftpAutomaton.build(false, CapabilityInit.BOTH, CapabilityMode.BOTH, 999999, 999); this.subscribe(MonitorEvent.class, oftp); oftp.subscribe(MonitorEvent.class, this); Thread oftpThread = new Thread(oftp); oftpThread.start(); System.out.println("Wait for connection"); ServerSocket server = new ServerSocket(LISTEN_PORT); Socket socket = server.accept(); server.close(); MonitorEvent nConInd = new MonitorEvent(new NetworkConnectionIndicationArchetype()); nConInd.putAttribute(AbstractSocketInitialisationArchetype.SOCKET, socket); publish(nConInd); oftpThread.join(); } catch (IOException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }