private void waitForConnection() throws IOException { addThreadToInterrupt(); try { setStatus(ConnectionStatus.WAITING_FOR_CONNECTION, null); LOG.debug("waiting for connection on port " + getPort()); final Socket socket = myServerSocket.accept(); try { attachToSocket(socket); } finally { socket.close(); } } finally { myServerSocket.close(); removeThreadToInterrupt(); } }
public void open() throws IOException { myServerSocket = createSocket(); setPort(myServerSocket.getLocalPort()); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { try { waitForConnection(); } catch (IOException e) { LOG.info(e); setStatus(ConnectionStatus.CONNECTION_FAILED, "Connection failed: " + e.getMessage()); } } }); }