public void run() { String url = formPushListenUrl(); try { socket = (ServerSocketConnection) Connector.open(url); } catch (IOException ex) { System.out.println("can't open the port, probably taken by another application " + ex); ex.printStackTrace(); } while (running) { try { Object o = socket.acceptAndOpen(); conn = (HttpServerConnection) o; inputStream = conn.openInputStream(); pushInputStream = new MDSPushInputStream(conn, inputStream); process(pushInputStream); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); if (running) { running = false; } } finally { Messaging.close(conn, pushInputStream, null); } } }