import java.awt.* ; import java.net.* ; import java.io.* ; public class ThreadExemple5 extends Thread { private Label lb ; private String host ; public ThreadExemple5(String s,Label l) { lb = l ; host = s ; } public void run() { boolean bRun = true ; while ( bRun) { Socket s ; int port = 5555 ; try { s = new Socket(host,port) ; InputStream is = s.getInputStream() ; DataInputStream ois = new DataInputStream(is) ; int hr = ois.readInt() ; int mn = ois.readInt() ; int sc = ois.readInt() ; int ml = ois.readInt() ; lb.setText("Heure sur "+host+" : "+hr+":"+mn+":"+sc+":"+ml) ; ois.close() ; } catch (UnknownHostException uhe) { bRun = false ; lb.setText(uhe.toString()) ; } catch (IOException ioe) { bRun = false ; lb.setText(ioe.toString()) ; } ; try { sleep(1000) ; } catch (Exception e) { } ; } } }