I have an app do this: send a String to server once in 10 seconds. But i don't know exactly how to do that and i don't have a server to test, so i have 2 ways that i think could be good. You guy can help me?! Thanks!
1. I put these in Run:
2. Put in function where i want it repeatCode:public void run() { try { int i = 0; i ++; try { Thread.sleep(10000); } catch (InterruptedException ex) { ex.printStackTrace(); } String s; while ( ! (s = is.readUTF()).equals("bye") ) { form.append("< " + s + "\n"); } } catch (IOException ex) { ex.printStackTrace(); form.append("[end]\n"); } }
Code:try { int i = 0; i ++; try { Thread.sleep(10000); } catch (InterruptedException ex) { ex.printStackTrace(); } os.writeUTF( "$ITP" + "," + s + "," + date + "," + time + "," + data + "\r"); os.flush(); } catch (IOException ioe)
Thanks for any help from nice guys here ^^

Reply With Quote




