import java.net.InetAddress; import java.net.UnknownHostException; import javax.swing.JApplet; public class test extends JApplet implements Runnable { private static final byte CAR_CR = 0x0D; private static final byte CAR_LF = 0x0A; private static final int portConsole = 10001; public static int Cslbegin; public static int Cslend; Thread me; boolean KeepRunning=true; private test1 Socket; int i=0; public static byte[] CslText = new byte[100]; private int CslIndex=0; private InetAddress reader_ip; public static boolean NewMsg; public void init() { try {reader_ip = InetAddress.getByName("134.214.56.200");} catch (UnknownHostException e) {} /* Open a socket to the Device Server's serial port */ if (reader_ip != null) { if (Socket == null) { Socket = new test1(reader_ip, portConsole); } } } public void start() { me=new Thread(this); me.setDaemon(true); me.start(); Socket.Poll.start(); } public void stop() { KeepRunning=false; } public void destroy() { } public void run() { while (KeepRunning) { try { Thread.sleep(1); } catch (InterruptedException e) { } if(NewMsg) { switch (CslText[CslIndex]) { case CAR_CR: System.out.println("Carriage Return"); break; case CAR_LF: System.out.println("Line Feed"); break; default: System.out.println("Caractère Imprimable"); } System.out.println("\t\t\t\t"+CslIndex); if(CslIndex==Cslend-1) { NewMsg=false; } else { CslIndex++; } } } } }